记得昨天有一个问了这个问题了. 先设置好stringgrid的列数等信息,然后向stringgrid的单元格中写数据就行了. 我这里有一个,数据集与string为参数的函数,你参照一下. procedure SetGridInfo(StrGrid:TStringGrid;sQuery:TAdoQuery); var i,j:integer; begin StrGrid.RowCount:=2; i:=1; while not sQuery.eof do begin StrGrid.Cells[0,i]:=inttostr(i); for j:=1 to sQuery.FieldCount do begin StrGrid.Cells[j,i]:=sQuery.Fields[j-1].AsString; end; i:=i+1; StrGrid.RowCount:=StrGrid.RowCount+1; sQuery.Next; end; end;
还是只要改变TstringGrid的属性就可以了!!!
添加控件事在TstringGrid里面,而不是在FORM上,高手快来帮忙啊
!
先设置好stringgrid的列数等信息,然后向stringgrid的单元格中写数据就行了.
我这里有一个,数据集与string为参数的函数,你参照一下.
procedure SetGridInfo(StrGrid:TStringGrid;sQuery:TAdoQuery);
var
i,j:integer;
begin
StrGrid.RowCount:=2;
i:=1;
while not sQuery.eof do
begin
StrGrid.Cells[0,i]:=inttostr(i);
for j:=1 to sQuery.FieldCount do
begin
StrGrid.Cells[j,i]:=sQuery.Fields[j-1].AsString;
end;
i:=i+1;
StrGrid.RowCount:=StrGrid.RowCount+1;
sQuery.Next;
end;
end;