Recent

Author Topic: [SOLVED] How to detect if a StringGrid was edited?  (Read 812 times)

Hartmut

  • Hero Member
  • *****
  • Posts: 736
[SOLVED] How to detect if a StringGrid was edited?
« on: December 04, 2023, 07:18:41 pm »
My program has a StringGrid where 2 columns are editable. To know, if I must save changes, I must know, if something was edited. Is there already somekind of Flag for this? Or must I do all this by my own? If yes, what would be the easiest approach?

I use Lazarus 2.0.10 with FPC 3.2.0. Thanks in advance.
« Last Edit: December 05, 2023, 11:46:32 am by Hartmut »

Josh

  • Hero Member
  • *****
  • Posts: 1269
Re: How to detect if a StringGrid was edited?
« Reply #1 on: December 04, 2023, 07:37:53 pm »
hi

tstringgrid does have a property you can read/write called modified.

if stringgrid.modified then ???

any change to grid contents will set the property to true, so after you populate your grid you need to set the property to false.

It s very basic, you may be better creating your own code to accomplish the same.
But you never know it may be enough for you.
« Last Edit: December 04, 2023, 08:00:07 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

dsiders

  • Hero Member
  • *****
  • Posts: 1017
Re: How to detect if a StringGrid was edited?
« Reply #2 on: December 04, 2023, 09:04:06 pm »
My program has a StringGrid where 2 columns are editable. To know, if I must save changes, I must know, if something was edited. Is there already somekind of Flag for this? Or must I do all this by my own? If yes, what would be the easiest approach?

I use Lazarus 2.0.10 with FPC 3.2.0. Thanks in advance.

More recent LCL versions include the Modified property (public). Not sure about your version.

https://lazarus-ccr.sourceforge.io/docs/lcl/grids/tcustomstringgrid.modified.html
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

jamie

  • Hero Member
  • *****
  • Posts: 6032
Re: How to detect if a StringGrid was edited?
« Reply #3 on: December 04, 2023, 11:38:49 pm »
That property is in 3.0.4 laz of the grid, so I don't think there is any concerns there.
The only true wisdom is knowing you know nothing

Hartmut

  • Hero Member
  • *****
  • Posts: 736
Re: How to detect if a StringGrid was edited?
« Reply #4 on: December 05, 2023, 11:46:07 am »
Many thanks to all for your answers and especially the documentation link. 'TStringGrid.Modified' does exist in Lazarus 2.0.10 and I think this will work for my purpose.

 

TinyPortal © 2005-2018