Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find a field value fo selected rows in dbgrid

Status
Not open for further replies.

rizunb

Programmer
Feb 27, 2003
63
CA
guys.
Ok user select few rows in the dbgrid
I can go findout how many rows are selected
but what i really want to find out is the value of an id of that row

I mean each row has an vISIT_ID field attached which is a number, what I want to know is the visit_id's of all the selected rows.

How do i do that?

Thanks
 
procedure TForm1.Button1Click(Sender: TObject);
var
i, j: Integer;
s: string;
aStringList : TStringList;
begin
aStringLIst := TStringList.Create;
if (DBGrid1.SelectedRows.Count > 0) then
with DBGrid1.DataSource.DataSet do
for i:=0 to DBGrid1.SelectedRows.Count-1 do
begin
GotoBookmark(pointer(DBGrid1.SelectedRows.Items));
AStringList.Add(FieldByName('VISIT_ID').asString);
end;
// do something with IDs in aStringList
aStringList.Free;
end;

--- McMerfy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top