Hi all.
I have a RichTextBox formatted to RTF. I need to lock down the text formatting of this RichTextBox to not allow any coloured font, italics etc. to be pasted in. I have a paste command and initially acheived this by calling the
I then tried to call
Here's my Paste command code:
Tom
I have a RichTextBox formatted to RTF. I need to lock down the text formatting of this RichTextBox to not allow any coloured font, italics etc. to be pasted in. I have a paste command and initially acheived this by calling the
Clipboard.GetText();
method which obviously returned a text string devoid of formatting. The problem with this method is that if I try to paste in Bullets for example, the text cannot render them.I then tried to call
Clipboard.GetText(TextDataFormat.Rtf);
This returns RTF into my RichTextBox along with bullets etc. but also carries over the font colour, size etc. that I wanted to strip out. Is there any way to bring in the Rtf string and strip formatting back? I thought about iterating over the Rtf string but the Rtf is quite complex!Here's my Paste command code:
private void FormatPastedTextCommandAction()
{
string ClipboardText = string.Empty;
ClipboardText = Clipboard.GetText(TextDataFormat.Rtf);
PastedText += ClipboardText;
}
Thanks,Tom