Recent

Author Topic: Does TStringGrid have 'OnCellEnter' event  (Read 1426 times)

Bert_Plitt

  • Jr. Member
  • **
  • Posts: 62
Does TStringGrid have 'OnCellEnter' event
« on: October 24, 2018, 12:25:44 am »
I have a TStringGrid on a form (Grid1) and two declared variables, Row, Col: integer.  I have an event called Grid1Click(Sender: TObject), which assigns the row and col values of the cell clicked on to Row and Col.  In addition to the mouse click, I want to trigger this event procedure whenever a cell receives focus, either by mouse click or arrow keys.  That is, I want the variables to track the position of the active cell as it is moved around in the grid.  Is there an "OnEnterCell" event available for the StringGrid?  Or what would the code be to implement such an event?
Windows 10, Lazarus 2.2.2, FPC 3.2.2

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Does TStringGrid have 'OnCellEnter' event
« Reply #1 on: October 24, 2018, 12:36:34 am »
OnSelectCell  is what you want I believe....

It reports the selected ROW and COL..

btw, this is in the help file that comes with Lazarus...

You may need to open the LCL file from the help interface to see it.
The only true wisdom is knowing you know nothing

Bert_Plitt

  • Jr. Member
  • **
  • Posts: 62
Re: Does TStringGrid have 'OnCellEnter' event
« Reply #2 on: October 24, 2018, 02:05:52 am »
Jamie --
It looks to me that OnSelectCell uses row and col as input parameters, but does not report them once a cell is selected.  That's not what I'm looking for.

The following code works for a mouse click, it reports where the click occurred:

var
  Row, Col: Integer;

procedure TForm1.Grid1Click(Sender: TObject);
  begin
    Row:=Grid1.Row;
    Cow:=Grid1.Col;
  end;

BTW - I could not find anything in the help system that explains how to use the OnSelectCell  event. 

Bert
Windows 10, Lazarus 2.2.2, FPC 3.2.2

Bert_Plitt

  • Jr. Member
  • **
  • Posts: 62
Re: Does TStringGrid have 'OnCellEnter' event (SOLVED)
« Reply #3 on: October 24, 2018, 02:18:08 am »
False alarm.  The OnClick event IS triggered when the celll selection is moved by the arrow keys.  Problem solved.
Windows 10, Lazarus 2.2.2, FPC 3.2.2

 

TinyPortal © 2005-2018