如何从RichTextBox删除附加的文本 [英] How to Remove Appended Text from RichTextBox
本文介绍了如何从RichTextBox删除附加的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用了appendText()函数将文本追加到RichTextBox中,现在如何清除RichTextBox的文本
在此先感谢.
I have used the appendText() function to append text to RichTextBox Now How do I clear the RichTextBox''s Text
Thanks in Advance.
推荐答案
使用 ^ ]
这是您不应该要做的事情:不为,并且不要将其分配给属性 Text
.不要尝试使用属性Rtf
做类似的事情. (这仅适用于System.Windows.Forms.RichTextBox
,不能用于WPFSystem.Windows.Controls.RichTextBox
.)
这是您应该做的:使用正确的SelectionStart
和SelectionEnd
选择所需的文本,然后将属性SelectedText
分配给string.Empty
.
另外,请注意:这些控件具有撤消功能;您可以使用它.
参见:
http://msdn.microsoft.com/en-us/library/system. windows.forms.richtextbox.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. windows.controls.richtextbox.aspx [ ^ ].
请始终标记要使用的UI库,不要让专家做双重工作!
—SA
Here is what you should not do: do not calculate new text for the instance ofRichTextBox
and do not assign it to the propertyText
. Do not try to do something like that with the propertyRtf
. (This is applicable toSystem.Windows.Forms.RichTextBox
only, you cannot do it for WPFSystem.Windows.Controls.RichTextBox
.)
Here is what you should do: select the text you need using the properlySelectionStart
andSelectionEnd
, then assign the propertySelectedText
tostring.Empty
.
Also, pay attention: these controls have Undo functionality; you can use it.
See:
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.aspx[^].
Please, always tag UI library you want to use, don''t make experts doing double work!
—SA
这篇关于如何从RichTextBox删除附加的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文