It seems that there is this ClearUndo()
method in a RichTextBox in Windows Forms (see system.windows.forms.textboxbase.).
似乎在Windows窗体的RichTextBox中有这个ClearUndo()方法(请参阅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.
我在RichTextBox Control中需要类似的东西。这是因为(正如这里提到的:防止将RichTextBox操作添加到控件的Undo堆栈中),每个更改都会添加到RichTextBox的撤消堆栈中。
I like to override OnTextChanged
event and remove some of these changes from Uno stack. How can I do that?
我喜欢重写OnTextChanged事件并从Uno堆栈中删除一些这些更改。我怎样才能做到这一点?
thanks.
谢谢。
1 个解决方案
#1
11
You can emulate ClearUndo()
for WPF RichTextBox
control with the following code:
您可以使用以下代码模拟WPF RichTextBox控件的ClearUndo():
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.
如果您仍想实现自己的撤消/重做机制,最简单,最直接的方法是在每个重要文本更改中将控件的整个文本存储在数组中。但是,只有当你不打算用控件编辑大文本时,我才会建议它。
#1
11
You can emulate ClearUndo()
for WPF RichTextBox
control with the following code:
您可以使用以下代码模拟WPF RichTextBox控件的ClearUndo():
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.
如果您仍想实现自己的撤消/重做机制,最简单,最直接的方法是在每个重要文本更改中将控件的整个文本存储在数组中。但是,只有当你不打算用控件编辑大文本时,我才会建议它。