Here is what you
should not do: do not calculate new text for the instance of
RichTextBox
and do not assign it to the property
Text
. Do not try to do something like that with the property
Rtf
. (This is applicable to
System.Windows.Forms.RichTextBox
only, you cannot do it for WPF
System.Windows.Controls.RichTextBox
.)
Here is what you
should do: select the text you need using the properly
SelectionStart
and
SelectionEnd
, then assign the property
SelectedText
to
string.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