Recent

Author Topic: TStringGrid: which event fires when checkbox is changed?  (Read 7437 times)

wimpie

  • New Member
  • *
  • Posts: 32
TStringGrid: which event fires when checkbox is changed?
« on: January 19, 2010, 06:51:34 am »
Hi

I have a stringgrid containing a column of checkboxes. Which event does one use to be informed of boxes that have been checked/unchecked?

LazaruX

  • Hero Member
  • *****
  • Posts: 597
  • Lazarus original cheetah.The cheetah doesn't cheat
Re: TStringGrid: which event fires when checkbox is changed?
« Reply #1 on: January 19, 2010, 10:09:55 am »
You can use something like OnChange and then check if the checkbox is in the status you wished

wimpie

  • New Member
  • *
  • Posts: 32
Re: TStringGrid: which event fires when checkbox is changed?
« Reply #2 on: January 19, 2010, 09:34:55 pm »
I don't think TStringGrid has an OnChange event. There are OnChange events for properties such as BorerSpacing and Constraints.

There is OnEditingDone, but it doesn't fire for the checkbox cells.


jesusr

  • Sr. Member
  • ****
  • Posts: 482
Re: TStringGrid: which event fires when checkbox is changed?
« Reply #3 on: January 20, 2010, 09:58:02 pm »
Right, the grid didn't have a easy way to detect checkbox toggle, in Lazarus 23510 I have added a new event: OnCheckboxToggled it has an aState argument that indicates what was the final state of checkbox, this event is triggered for currently cell, ie, grid.col, grid.row.

wimpie

  • New Member
  • *
  • Posts: 32
Re: TStringGrid: which event fires when checkbox is changed?
« Reply #4 on: January 21, 2010, 07:34:39 am »
Thank you. It helps me a lot.

I think it will be better if the Col and Row is also passed as parameters. It will reduce the code in the handler and be in line with the other grid events. But it is not critical. I will log a feature request on mantis.

Thanks again.

Bitbeisser

  • New Member
  • *
  • Posts: 16
Re: TStringGrid: which event fires when checkbox is changed?
« Reply #5 on: August 09, 2022, 10:29:23 pm »
Right, the grid didn't have a easy way to detect checkbox toggle, in Lazarus 23510 I have added a new event: OnCheckboxToggled it has an aState argument that indicates what was the final state of checkbox, this event is triggered for currently cell, ie, grid.col, grid.row.
I know the post is more than 12 years old, but did this ever make it into an official release of Lazarus? I have the same problem right now where I would need to get an event fired up when the checkbox in the first column of a tStringGrid gets changed. But overall documentation of the use of those checkboxes is rather thin in general and there is no event shown in the Object Inspector for either the column or the cell with the checkbox(es)...

PS: Never mind, I think I found it. tStringgrid.OnCheckBoxToggled seems to be what I was looking for...
« Last Edit: August 09, 2022, 10:41:49 pm by Bitbeisser »

 

TinyPortal © 2005-2018