[Lazarus] Grid Cell Editors

Vojtěch Čihák vojtech.cihak at atlas.cz
Fri Jul 1 12:07:25 CEST 2016


Hello,
 
I use TStringGrid with my own cell editors and I would like to implement following feature:
Column of edited cell will be automaticaly enlarged when cell editor appears (and auto-shrinked afterwards).
 
But I do not use goAlwaysShowEditor and grid triggers OnSelectEditor events even if it actually is not going to show editor.
(the first click selects cell, triggers OnSelectEditor but no editor is shown yet,
 the second click on the selected cell triggers OnSelectEditor again and now editor appears).
 
I need to detect in OnSelectEditor whether the grid is really going to show the editor.
 
So far I have this:
 
TStrGridAccess = class(TStringGrid);  {for access to protected properties}
 
if (TStrGridAccess(Sender).FGridState=gsSelecting) and not TStringGrid(Sender).EditorMode
  and not (gfNeedsSelectActive in TStrGridAccess(Sender).GridFlags) then writeln('Now!'); 
 
It seems to be reliable but of course, it's a hack. Is there a better way?
 
Thanks, V.


More information about the Lazarus mailing list