Recent

Author Topic: [Solved] fpWorksheetGrid change  (Read 1703 times)

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
[Solved] fpWorksheetGrid change
« on: October 21, 2017, 02:56:11 pm »
Hi,

A quick question (hopefully); is there a way of knowing if a fpWorksheetGrid has changed?

Thanks
Dave
« Last Edit: October 22, 2017, 02:30:23 am by daveinhull »
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: fpWorksheetGrid change
« Reply #1 on: October 21, 2017, 03:26:00 pm »
You have the events exposed for the standard Lazarus grid controls, in particular OnEditingDone (when editing of a cell is completed by pressing ENTER or navigating to another cell):

Code: Pascal  [Select][+][-]
  1. procedure TForm1.sWorksheetGrid1EditingDone(Sender: TObject);
  2. begin
  3.   Label1.caption := sWorksheetGrid1.Cells[sWorksheetGrid1.Col, sWorksheetGrid1.Row];
  4. end;  

Since this is a grid-event it does not fire if you modify the underlying worksheet by code. There is an internal event for this case (Worksheet.OnChangeCell), but since this is used for internal communication between visual and non-visual fpspreadsheet components I do not recommend its usage. On the other hand, since the worksheet is modified by code you exactly know when this happens and you can react accordingly.

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Re: fpWorksheetGrid change
« Reply #2 on: October 22, 2017, 02:29:00 am »
Thanks again #wp, I'd got the EditDone one, but the internal event was what I was looking for.
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

 

TinyPortal © 2005-2018