It seems that there is this ClearUndo()
method in a RichTextBox in Windows Forms (see system.windows.forms.textboxbase.).
I need something similar in RichTextBox Control
. This is because (as it is mentioned here: Preventing a RichTextBox operation from being added to the control's Undo stack) every change is added to the RichTextBox's undo stack.
I like to override OnTextChanged
event and remove some of these changes from Uno stack. How can I do that?
thanks.
You can emulate ClearUndo()
for WPF RichTextBox
control with the following code:
richTextBox.IsUndoEnabled = false;
richTextBox.IsUndoEnabled = true;
But there's no way you can control any particular actions in the Undo
list.
If you still want to implement your own Undo/Redo
mechanism, the easiest and the most straightforward way is to store in an array the whole text of the control on each significant text change. But I would advise it only if you're not planning to edit large text with the control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With