Recent

Author Topic: Calling select/unselect events  (Read 244 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1002
Calling select/unselect events
« 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. 

Zvoni

  • Hero Member
  • *****
  • Posts: 1339
Re: Calling select/unselect events
« Reply #1 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.  
« Last Edit: August 11, 2022, 02:16:17 pm by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

egsuh

  • Hero Member
  • *****
  • Posts: 1002
Re: Calling select/unselect events
« Reply #2 on: August 12, 2022, 10:35:06 am »
I think OnSelect is called whenever mouse is over a cell, while the TStringGrid is focused.

Zvoni

  • Hero Member
  • *****
  • Posts: 1339
Re: Calling select/unselect events
« Reply #3 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
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

jamie

  • Hero Member
  • *****
  • Posts: 4755
Re: Calling select/unselect events
« Reply #4 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.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018