Board index » delphi » Multiple row selection in TDBGrid

Multiple row selection in TDBGrid

I've made it possible for the user to select multiple rows in a
TDBGrid (RowSelect=True,MultiSelect=True). How does one determine
which rows the user has selected?

Any help would be appreciated.

 

Re:Multiple row selection in TDBGrid


I saw in the documentation you can reference the SELECTEDROWS property.  It
states that it is a "set of bookmarks to all the records in the dataset
that correspond to rows selected in the grid."  Do they really mean a
"set"? Because the class type for this property is TBookmarkList?  That
almost implies TList descendent to me but you it states it is a "set"!?!
Since there is nowhere in the help docs I could find what a TBookmarkList
is, I found a TBookmark Type.  The "TBookmark is a pointer passed to the
GetBookmark, GotoBookmark, and FreeBookmark methods."  You can then use the
GetBookmark and Gotobookmark methods of TDataSet.  

The Help Docs really stink on this topic because it appears there are some
broken links to the TBookmarkList pages.  A "Find" in the Help may reveal
something....

If they mean it is a set [one, two, three], I'm not sure how you would get
this list but if the property returns a list of TBookmarks then I would
think it looks something like this....

for i := 0 to MyGrid.SelectedRows.Count - 1 do begin
   MyGrid.Datasource.DataSet.DisableControls;
   MyGrid.DataSource.DataSet.GotoBookmark(MyGrid.SelectedRows.items[i])

Showmessage(MyGrid.DataSource.DataSet.FieldByName('OneOfMyFieldNames').AsStr
ing);    {do your processing here}
   MyGrid.Datasource.DataSet.EnableControls;  
end;

I'd imagine it's something like this....

Randy Trexler
Department of Veteran Affairs

Maurice Valmont <Mauri...@bellsouth.net> wrote in article
<3490564d.2115...@news.atl.bellsouth.net>...

Quote
> I've made it possible for the user to select multiple rows in a
> TDBGrid (RowSelect=True,MultiSelect=True). How does one determine
> which rows the user has selected?

> Any help would be appreciated.

Re:Multiple row selection in TDBGrid


On 12 Dec 97 13:59:42 GMT, "Randy W. Trexler"

Quote
<randy.trex...@med.va.gov> wrote:
>I saw in the documentation you can reference the SELECTEDROWS property.  It
>states that it is a "set of bookmarks to all the records in the dataset
>that correspond to rows selected in the grid."  Do they really mean a
>"set"? Because the class type for this property is TBookmarkList?  That
>almost implies TList descendent to me but you it states it is a "set"!?!
>Since there is nowhere in the help docs I could find what a TBookmarkList
>is, I found a TBookmark Type.  The "TBookmark is a pointer passed to the
>GetBookmark, GotoBookmark, and FreeBookmark methods."  You can then use the
>GetBookmark and Gotobookmark methods of TDataSet.  

>The Help Docs really stink on this topic because it appears there are some
>broken links to the TBookmarkList pages.  A "Find" in the Help may reveal
>something....

>If they mean it is a set [one, two, three], I'm not sure how you would get
>this list but if the property returns a list of TBookmarks then I would
>think it looks something like this....

>for i := 0 to MyGrid.SelectedRows.Count - 1 do begin
>   MyGrid.Datasource.DataSet.DisableControls;
>   MyGrid.DataSource.DataSet.GotoBookmark(MyGrid.SelectedRows.items[i])

>Showmessage(MyGrid.DataSource.DataSet.FieldByName('OneOfMyFieldNames').AsStr
>ing);    {do your processing here}
>   MyGrid.Datasource.DataSet.EnableControls;  
>end;

>I'd imagine it's something like this....

>Randy Trexler
>Department of Veteran Affairs

>Maurice Valmont <Mauri...@bellsouth.net> wrote in article
><3490564d.2115...@news.atl.bellsouth.net>...
>> I've made it possible for the user to select multiple rows in a
>> TDBGrid (RowSelect=True,MultiSelect=True). How does one determine
>> which rows the user has selected?

>> Any help would be appreciated.

Thank you for your trouble, and thanks to Reid Roman who provided the
complete documentation. I wonder whether Borland would contract us to
fix their on-line help system? ;-)

Other Threads