 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gunnar Liknes Guest
|
Posted: Tue Aug 10, 2004 3:43 pm Post subject: TDBGrid and Multiselection |
|
|
Hi,
I have searched allover the place but cannot find a simple solution to this
simple
problem:
I have a TDBGrid which displayes the result of a query. I have enabled
multiselect and rowselect.
Problem:
When the user changes the selection I need to update a label with
information
about the selection. For now I just set the labels caption to the number of
rows
selected.
Howeever I cannot find any event that triggers when the selection change. I
have
found a few which trigger when the active record change (i.e.
Dataset.Afterscroll,
dataset.omMoveComplete and datasource on dataChange), however it seems like
theese events fire before the new row is added to the selection as
Selectedrows.count
is always 1 less than it should be if I update the label inside one of them.
I have tried to put the following code inside almost any data/row change
event in
the object inspector:
Label26.Caption:=intToStr(DBGrid1.SelectedRows.Count);
DBGrid1.SelectedRows.Count is always 1 less than the actual rows selected.
If I add the same line in a Tbutton's onclick event the SelectedRows.Count
value is correct;
Is there any solution to this?
Cheers
Gunnar
|
|
| Back to top |
|
 |
Gunnar Liknes Guest
|
Posted: Tue Aug 10, 2004 4:17 pm Post subject: Re: TDBGrid and Multiselection |
|
|
"Gunnar Liknes" wrote
| Quote: | I have a TDBGrid which displayes the result of a query. I have enabled
multiselect and rowselect.
Problem:
When the user changes the selection I need to update a label with
information
about the selection. For now I just set the labels caption to the number
of
rows
selected.
Howeever I cannot find any event that triggers when the selection change.
I
have
found a few which trigger when the active record change (i.e.
Dataset.Afterscroll,
dataset.omMoveComplete and datasource on dataChange), however it seems
like
theese events fire before the new row is added to the selection as
Selectedrows.count
is always 1 less than it should be if I update the label inside one of
them. |
I found a solution myself:
If I send a message to myself in the DataSource.DataChange event like this:
PostMessage(Self.Handle, UM_SelectionChange, 0,0);
Then RowsSelected.count is updated by the time I get the message, and I
can do my stuff in the messagehandler .
Regards
Gunnar
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|