Browse a Dbgrid in Delphi

ryldor Posted messages 145 Status Member -  
 hshamsan -
Hello,

I am new to Delphi and I would like to know how to iterate through a dbgrid. More specifically, I would like to know the syntax for traversing the dbgrid.

I know that I need to use a loop and test the fields, but I am unsure of the syntax.

If you could help me!
Configuration: Windows Vista Internet Explorer 7.0

1 answer

hshamsan
 
Your DBGrid is linked to ClientDataSet, isn't it?

So, use this:

ClientDataSet1.First;
while not ClientDataSet1.Eof do
begin
for i:=0 to ClientDataSet1.FieldCount-1 do
begin

Memo1.Text:=Memo1.Text+ClientDataSet1.Fields[i].AsString;
end;
ClientDataSet1.Next;
end;
0