FabDev 8 Posted June 21 (edited) Hello, On a basic TMemo (or any TEdit) Undo work by default when the end user modify something. Problem if you change something by code like a simple : Memo1.Seltext:='Bob'; After this Undo (CTRL + Z ) will not work for the user. If he want to cancel my "Bob". So how to force a modification by code to be in Undo stack ? Edited June 21 by FabDev Share this post Link to post
Lajos Juhász 293 Posted June 21 It is an easy to debug. You have to set the CanUndoSelText property to true. https://docwiki.embarcadero.com/Libraries/Alexandria/en/Vcl.StdCtrls.TCustomEdit.CanUndoSelText 1 Share this post Link to post
FabDev 8 Posted June 21 (edited) I did not know this CanUndoSelText method, but It's exactly that I need. Thank you very much ! Edited June 21 by FabDev Share this post Link to post
Lajos Juhász 293 Posted June 21 It was introduced recently. Delphi XE5 does not have it yet. Share this post Link to post
Remy Lebeau 1396 Posted June 21 5 hours ago, Lajos Juhász said: It was introduced recently. Delphi XE5 does not have it yet. It was added in 11.0 Alexandria. http://docwiki.embarcadero.com/RADStudio/Alexandria/en/What's_New#Smaller_Changes Quote Smaller Changes SetSelText and SetSelTextBuf offer the option not to reset the Undo buffer. This is managed by a new property CanUndoSelText. It is False by default, which maintains backwards compatibility. If set to True it allows Undo to be called (or an Undo operation to be invoked with the UI) to undo a change made with calls to SetSelText or SetSelTextBuf or by assignments to the SelText property. Share this post Link to post