Recent

Author Topic: [SOLVED] DrawGrid and StringGrid: wrong behaviour in OnCheckboxToggled event  (Read 491 times)

mizar

  • New Member
  • *
  • Posts: 42
Hi all,
attached is a sample program to better explain what I found (fpc 3.2.3 - Lazarus 3.4-37, linux 64bit (fpcupdeluxe)):

If you put on a form a DrawGrid or a StringGrid  and one or more columns are of type CheckboxColumns, setting the proper handler (at least for DrawGrid) for OnCheckboxToggled event, it happens that if some empty space is left at the right of the last column and/or at the bottom of the last row, clicking in this empty space triggers OnCheckboxToggled event and the parameters aRow and aCol are set respectively to last row and/or last column.  :(

So if, by chance, there is a mouse click in that empty space last column and/or last row is affected without the user had intention to.  >:D

Am I missing something ? Any help appreciated. Thank you.

The same behaviour in Linux and Windows
« Last Edit: July 07, 2024, 05:47:21 pm by mizar »

wp

  • Hero Member
  • *****
  • Posts: 12457
Re: DrawGrid and StringGrid: wrong behaviour in OnCheckboxToggled event
« Reply #1 on: July 07, 2024, 05:12:57 pm »
Add the following instructions to the form's OnCreate handler:
Code: Pascal  [Select][+][-]
  1.   DrawGrid1.AllowOutboundEvents := false;
  2.   StringGrid1.AllowOutboundEvents := false;  

See https://wiki.lazarus.freepascal.org/Grids_Reference_Page#property_AllowOutboundEvents

mizar

  • New Member
  • *
  • Posts: 42
Thank you wp  :)

 

TinyPortal © 2005-2018