Reputation: 2133
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.
Upvotes: 8
Views: 2140
Reputation: 3770
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.
Upvotes: 13