Board index » delphi » multiselect in dbgrid

multiselect in dbgrid

How does one use the multiselect?

I selected a few records, then looked at the string in the bookmark, ie
s := grid.SelectedRows.Items[count];

The string contains nothing. What is inserted in the selected rows
string? How does one access it?

Another problem. When I select a few records, then press right mouse
button to popup menu, it deselects all but the one under the mouse
pointer. How does one fix that?

Derek Kite

 

Re:multiselect in dbgrid


As with all the values in the DBGrid, you access values in selected rows by
the Dataset's field properties:

If grid.SelectedRows.CurrentRowSelected = True then
    S := Query1.FieldByName('YourColumn').AsString;

--
Michael Glatz
mgl...@caiso.com

Quote
Doug Hamilton wrote in message <365EE31B.857BC...@netidea.com>...
>How does one use the multiselect?

>I selected a few records, then looked at the string in the bookmark, ie
>s := grid.SelectedRows.Items[count];

>The string contains nothing. What is inserted in the selected rows
>string? How does one access it?

>Another problem. When I select a few records, then press right mouse
>button to popup menu, it deselects all but the one under the mouse
>pointer. How does one fix that?

>Derek Kite

Re:multiselect in dbgrid


Michael: Ok. How do you find which records are selected? The currentrowselected
is the current record in the table. Do you run through all the records and
check each one if it is is in the tbookmarklist? Or is there some kind of
pointer to each record somewhere?

I suppose you could assume that the current record is the last one of a
selection running either forward or backwards through the table. I think the
way the records are selected is with shift-up or down arrow. Seems kinda
cludgy.

Derek

Quote
Michael Glatz wrote:
> As with all the values in the DBGrid, you access values in selected rows by
> the Dataset's field properties:

> If grid.SelectedRows.CurrentRowSelected = True then
>     S := Query1.FieldByName('YourColumn').AsString;

> --
> Michael Glatz
> mgl...@caiso.com
> Doug Hamilton wrote in message <365EE31B.857BC...@netidea.com>...
> >How does one use the multiselect?

> >I selected a few records, then looked at the string in the bookmark, ie
> >s := grid.SelectedRows.Items[count];

> >The string contains nothing. What is inserted in the selected rows
> >string? How does one access it?

> >Another problem. When I select a few records, then press right mouse
> >button to popup menu, it deselects all but the one under the mouse
> >pointer. How does one fix that?

> >Derek Kite

Other Threads