我也没有发现,只有借助于一个临时的stringlist然后进行删除了。
要么下载一个增强的控件
要么下载一个增强的控件
解决方案 »
- 求助 关于 PrintDBGridEh Options属性
- idftp使用代理上传文件出现 socket 10060 错误
- 基础解码,碰到位置上的问题
- ClientDataSet 数据保存问题,有的能保存,有的不能保存
- 关于多线程的奇怪问题,实际为什么和书上写的不一样???
- 请问高手怎样将TMemoryStream和Handle关联起来
- 请高手指教!
- 求助!!!我使用listbox控件,如果现在的记录太长就没有办法看到。我想加个水平的滚动条,不知道怎么做啊
- 问一个鼠标按键问题.分全部散给你们.RMB也行
- ****如何用QuickReport把Memo字段打印出来****
- 哪位大大虾,用dephi写过类似delphi里的winsight的监视系统消息的工具?请指点一二.....
- 关于数据加密的问题
去这个站点看看
You can always use a DBGrid to display a Query Result, but if you don´t need the overhead of data aware components, you can use the following function to populate a StringGrid with the result of a SQL sentence.
Answer:
Procedure QueryGrid(DBName, Statement: String; Target: TStringGrid; Titles: Boolean);
Var Col, Lin: Integer;
begin
With TQuery.Create(Nil) Do
Try
DatabaseName := DBName;
SQL.Text := Statement;
Open;
If Not IsEmpty Then
Begin
Target.ColCount := FieldCount;
Target.RowCount := RecordCount+ IIF(Titles,1,0);
Target.FixedCols := 0;
Target.FixedRows := IIF(Titles,1,0);
If Titles Then
For Col := 0 To FieldCount-1 Do
Target.Cells[Col,0] := Fields[Col].FieldName;
Lin := 0;
While Not Eof Do
Begin
For Col := 0 To FieldCount-1 Do
Target.Cells[Col,Lin+Target.FixedRows] :=
Fields[Col].AsString;
Next;
Inc(Lin);
End;
End;
Finally
Close;
Free;
End;
end; { QueryGrid }
E-mail:[email protected]