// start is the starting position of the protected text.
// end is the final position of the protected text.
// OPTION #1: Results in two "undo" entries.
MyRichTextBox.SelectionStart = start;
MyRichTextBox.SelectionLength = end - start + 1;
MyRichTextBox.SelectionProtected = false;
MyRichTextBox.SelectedRtf = "";
// OPTION #2: Results in "undo" buffer being initialized.
RichTextBox temp = new RichTextBox();
temp.Rtf = MyRichTextBox.Rtf;
temp.SelectionStart = start;
temp.SelectionLength = end - start + 1;
temp.SelectionProtected = false;
temp.SelectedRtf = "";
MyRichTextBox.Rtf = temp.Rtf;
temp.Dispose();
chanmm wrote:
Do you have some code to explain what you said?
chanmm
<ML****@hotmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
I need to programmatically delete protected text in a RichTextBox. The
problem is that I can't find a way to do it without getting
undesirable results in the undo buffer.
If I unprotect the text and delete, 2 entries go into the undo buffer.
If the user performs a single undo, they get back the text unprotected.
If I copy the entire RTF text, make my changes and copy it back, the
undo buffer is initialized.
Any ideas?
Thanks!