我有delphi 7。
我想在dbgrid中搜索数据。
我已经使用adotable和数据源链接到excel。
我在网上搜索过,只找到如何创建一个新的excel文档或如何链接该excel文档。
但是我想在所有行中搜索第一列
发布于 2013-06-13 22:40:13
一旦Excel被加载到ADOTable中,它就像任何其他普通表格一样。
最好不要在网格中搜索。为此,请使用AdoTable的Locate方法。
//or using [loCaseInsensitive,loPartialKey] options
ADOTable1.Locate('FieldName', 'Value', []); 您可能希望使用DisableControls和EnableControls来避免在定位所需值时以图形方式刷新网格,并使用书签返回到原始位置。
HTH
发布于 2013-06-16 06:58:40
是的,定位是更好的选择。您的DBGrid已链接到ClientDataSet或查询,请在DataSource上使用de Locate。
MyClientDataSet.Locate( ....更多细节,在你的delphi代码中,选择单词Locate,用F1打开你在delphi中的帮助。
发布于 2016-06-13 23:13:24
while not adoquery1.Eof do
begin
for I := 0 to adoquery1.FieldCount-1 do
if (enhdbgrid1.Fields[i].value<>null) and (pos(uppercase(edit1.Text),uppercase(enhdbgrid1.Fields[i].Value))>0) then
begin
Found := True;
enhDBGrid1.SelectedField := enhdbgrid1.Fields[i];
Break;
end;
if found then break;
adoquery1.Next;
end;https://stackoverflow.com/questions/17089687
复制相似问题