Lazarus

Programming => LCL => Topic started by: egsuh on August 11, 2022, 01:59:47 pm

Title: Calling select/unselect events
Post by: egsuh on August 11, 2022, 01:59:47 pm
Hi,
With TListView, I can assign codes to events when an item is un/selected.
I'd like to do this with TStringGrid, but it responds when I just put mouse over it.
Please try attached example, and please let me know if there are other ways with TStringGrids. 
Title: Re: Calling select/unselect events
Post by: Zvoni on August 11, 2022, 02:14:16 pm
Use the OnSelection-Event of the TStringGrid?
Then it's easy to check selection if Option goRowSelect is activated
Code: Pascal  [Select][+][-]
  1. procedure TMyForm.MyStringGridSelection(Sender: TObject; aCol, aRow: Integer);
  2. begin
  3.   If MyStringGrid.IsCellSelected[aCol,aRow] Then DoSomething;
  4. end;      
  5.  
Title: Re: Calling select/unselect events
Post by: egsuh on August 12, 2022, 10:35:06 am
I think OnSelect is called whenever mouse is over a cell, while the TStringGrid is focused.
Title: Re: Calling select/unselect events
Post by: Zvoni on August 12, 2022, 10:38:28 am
I think OnSelect is called whenever mouse is over a cell, while the TStringGrid is focused.
What makes you tink that?
I actually have a small project currently using a StringGrid where i evaluate the OnSelection-Event checking if the Row is selected or not.
Hovering the Mouse above doesn't fire the event
Title: Re: Calling select/unselect events
Post by: jamie on August 13, 2022, 04:38:22 pm
I think OnSelect is called whenever mouse is over a cell, while the TStringGrid is focused.

That would cause lots of problems if that were the case.

I just checked an older version of Laz, and it seems not to fire with mouse hover over cells.

If this is happening in other widgets or present versions, then report it.
TinyPortal © 2005-2018