type
TExCell = class(TStringGrid)
public
procedure DeleteRow(ARow: Longint)
procedure DeleteColumn(ACol: Longint)
procedure InsertRow(ARow: LongInt)
procedure InsertColumn(ACol: LongInt)
end
procedure TExCell.InsertColumn(ACol: Integer)
begin
ColCount :=ColCount +1
MoveColumn(ColCount-1, ACol)
end
procedure TExCell.InsertRow(ARow: Integer)
begin
RowCount :=RowCount +1
MoveRow(RowCount-1, ARow)
end
procedure TExCell.DeleteColumn(ACol: Longint)
begin
MoveColumn(ACol, ColCount -1)
ColCount := ColCount - 1
end
procedure TExCell.DeleteRow(ARow: Longint)
begin
MoveRow(ARow, RowCount - 1)
RowCount := RowCount - 1
end.
一、建议可以直接使用 dbGrid 或其它带数据感知的表格控件。
二、如果使用 StringGrid 控件,代码大致如下:
procedure TForm1.Button1Click(Sender: TObject)var iRow: integer
begin
StringGrid1.RowCount := ADOQuery1.RecordCount+1
ADOQuery1.First
iRow := 1
while not ADOQuery1.Eof do
begin
StringGrid1.Cells[1,iRow] := ADOQuery1.FieldByName('Jzlb').AsString
StringGrid1.Cells[2,iRow] := ADOQuery1.FieldByName('xm').AsString
StringGrid1.Cells[3,iRow] := ADOQuery1.FieldByName('xb').AsString
StringGrid1.Cells[4,iRow] := ADOQuery1.FieldByName('sfzh').AsString
iRow := iRow+1
ADOQuery1.Next
end
end
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)