Board index » delphi » How to identify selected rows in a DBGrid???

How to identify selected rows in a DBGrid???

Hi,
i'd like to take the datasets from a DBGrid (multi-selection) in a modal

dialog box to another DBGrid (in another form).
My problem is, how to get an idetification number or row index, to find
out which datasets are selected and how to get them into another DBGrid.

I tried half a day with the handbooks and online help but i haven't
found an answer.

Bye, Andreas

P.S.: I use Delphi4 Client/Server

 

Re:How to identify selected rows in a DBGrid???


Andreas,

Look in help for TDBGrid.SelectedRows, TDBGrid.SelectedRows.Count,
TDBGrid.SelectedRows.CurrentRowSelected etc.

You can iterate through the table and check the boolean value of
CurrentRowSelected to copy them to another table.

Rick

Quote
Schmid Software wrote in message <36497EB5.A706...@schmid-software.de>...
>Hi,
>i'd like to take the datasets from a DBGrid (multi-selection) in a modal

>dialog box to another DBGrid (in another form).
>My problem is, how to get an idetification number or row index, to find
>out which datasets are selected and how to get them into another DBGrid.

>I tried half a day with the handbooks and online help but i haven't
>found an answer.

>Bye, Andreas

>P.S.: I use Delphi4 Client/Server

Re:How to identify selected rows in a DBGrid???


The following code shows how to find the selected rows.  Is that what you
need?

  procedure TfrmGrid.Button1Click(Sender: TObject);
  var
     i:integer;
  begin
       For i:=0 to DBGrid1.SelectedRows.Count -1 do begin
           Table1.GoToBookmark(TBookmark(DBGrid1.SelectedRows[i]));
           Table1.Delete;
       end;
  end;

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Other Threads