Board index » delphi » DBGrid, SelectedRows and TBookmarkList

DBGrid, SelectedRows and TBookmarkList

In my Delphi package, the help file for the SelectedRows property of TDBGrid
says that:

"SelectedRows is a set of bookmarks to all the records in the dataset that
correspond to rows selected in the grid.

property SelectedRows: TBookmarkList"

but it does not document at all which are the properties, methods and events
of this class called TBookmarkList. I tried to tackle with it but I couldn't
figure out everything I needed to know...

Can somebody give me a hand on how to be able to process the selected rows
in a DBGrid (from the underlying table) and do whatever with these rows?

Thanks a lot!

D.

 

Re:DBGrid, SelectedRows and TBookmarkList


It's a TStrings Object.

Each of the Strings in the List represents a Bookmark of a Record.

Just assign one of the strings to the Bookmark property of the underlying
dataset and the Dataset wil jump to that record.

Re:DBGrid, SelectedRows and TBookmarkList


Daniel,

IF Form1.DBGrid1.SelectedRows.CurrentRowSelected
      then  { do something }

Hope this helps,
Alfred.

Daniel Stoian heeft geschreven in bericht ...

Quote
>In my Delphi package, the help file for the SelectedRows property of
TDBGrid
>says that:

>"SelectedRows is a set of bookmarks to all the records in the dataset that
>correspond to rows selected in the grid.

>property SelectedRows: TBookmarkList"

>but it does not document at all which are the properties, methods and
events
>of this class called TBookmarkList. I tried to tackle with it but I
couldn't
>figure out everything I needed to know...

>Can somebody give me a hand on how to be able to process the selected rows
>in a DBGrid (from the underlying table) and do whatever with these rows?

>Thanks a lot!

>D.

Re:DBGrid, SelectedRows and TBookmarkList


Yes, but how can I do something like this:

     for i := 0 to dbgrid1.SelectedRows.Count-1 do begin
        {identify the current record - (a)}
        {then add it to another table - (b)}
     end;   ...?

(a) I don't know this - maybe what Gerrit Moeller suggested will work. I'm
on the way of trying that... Do you have another hint?
(b) I know how to do this.

Thanks to you all. You're really wonderful people.

Quote
Alfred ten Hoeve wrote in message

<935104187.488...@jive.news.big-orange.net>...
Quote
>Daniel,

>IF Form1.DBGrid1.SelectedRows.CurrentRowSelected
>      then  { do something }

>Hope this helps,
>Alfred.

Re:DBGrid, SelectedRows and TBookmarkList


Re:DBGrid, SelectedRows and TBookmarkList


Actually it finally worked this way:

 for i := 0 to DBGrid1.SelectedRows.Count-1 do begin
   Tbl1.Bookmark := DBGrid1.SelectedRows.Items[i];
   {do something with the current selected record here, for example:}
   Tbl2.AppendRecord([Tbl1.Fields[0]]);
 end;

Thanks Gerrit, Alfred... now I can peacefully have my lunch snack :)

Re:DBGrid, SelectedRows and TBookmarkList


Re:DBGrid, SelectedRows and TBookmarkList


for i := 0 to SMDBGrid.SelectedRows.Count-1 do
begin
     {go to selected record}
   SMDBGrid.DataSource.DataSet.Bookmark := SMDBGrid.SelectedRows[i];

    {show a first field value}
    ShowMessage(SMDBGrid.DataSource.DataSet.FieldByName[0].AsString)
end;

--
With best regards, Mike Shkolnik.
FIDO: 2:463/106.14
E-Mail: mshkol...@rs-ukraine.kiev.ua
        m...@woccu.freenet.kiev.ua
WEB: http://www.geocities.com/SiliconValley/Grid/3989

Daniel Stoian D??? ???Y?? ...

Quote
>Yes, but how can I do something like this:

>     for i := 0 to dbgrid1.SelectedRows.Count-1 do begin
>        {identify the current record - (a)}
>        {then add it to another table - (b)}
>     end;   ...?

>(a) I don't know this - maybe what Gerrit Moeller suggested will work. I'm
>on the way of trying that... Do you have another hint?
>(b) I know how to do this.

>Thanks to you all. You're really wonderful people.

>Alfred ten Hoeve wrote in message
><935104187.488...@jive.news.big-orange.net>...
>>Daniel,

>>IF Form1.DBGrid1.SelectedRows.CurrentRowSelected
>>      then  { do something }

>>Hope this helps,
>>Alfred.

Other Threads