Recent

Author Topic: How to update cell text after custom edit?  (Read 194 times)

Marion

  • Full Member
  • ***
  • Posts: 106
How to update cell text after custom edit?
« on: December 03, 2022, 04:14:50 pm »
I remember doing this years ago. I also remember some better documentation on this but I can't find it now.

I'm using a TStringGrid with custom editors. I have everything working except updating the cell's text when the editing is done.

I have tried the OnEditDone, OnGetEditText, etc. What is the right way to update the cell text?
Thank you,
Marion
(A recovering Windows programmer.)

jamie

  • Hero Member
  • *****
  • Posts: 5197
Re: How to update cell text after custom edit?
« Reply #1 on: December 03, 2022, 04:37:31 pm »
OnEditoringDone would be my choice.

I don't know how you derived your custom editor, but I mainly subclass the already Existing TStringCellEditor which has the EditingDone as an overload option.
 
 There is one cavet to using the TEDITOR and the EditingDone and that is that it can fire when pressing the ENTER key but still be on there and it can fire when leaving the editor, so that means its twice if pressing the ENTER also propagates to the next location.

  What I do is test the focus in the EditingDone event to decide how that all plays out. You may not want to finalize the editing just from pressing the Enter key.

The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 10669
Re: How to update cell text after custom edit?
« Reply #2 on: December 03, 2022, 05:43:15 pm »
I have tried the OnEditDone, OnGetEditText, etc. What is the right way to update the cell text?
OnGetEditText: fires before editing begins. It moves the cell text to the editor.

OnSetEditText: Moves the editor content back into the cell. It definitely fires when editing is done. The default string cell editor, however, fires this event whenever the text changes.

 

TinyPortal © 2005-2018