I am using Rich Text object in my C# application. The only issue I am having is that when user pastes formated text from another app, it remains formated which I cannot have. Is there any way how to paste only string and ignore formatting?
Thanks!
I am using Rich Text object in my C# application. The only issue I
Share
Assuming WinForms : try this : define a RichTextBox with a KeyDown event handler like this :
Append-only example :
[Edit]
Add Clipboard RTF to RichTextBox at current insertion point (selection start) example :
[End Edit]
Note 0 : The pasted in text is going to assume the current style settings in effect for the RichTextBox : if you have ‘ForeGround color set to ‘Blue : the pasted in text is going to be in blue.
Note 1 : This is something I knocked together quickly, and tested only a few times by creating some multi-colored and weirdly formatted RTF for the clipboard using WordPad : then pasting into into the RichTextBox1 at run-time : it did strip away all the color, indenting, etc.
Since it’s not fully tested, use caution.
Note 2 : This will not handle the case of ‘Insert or ‘Paste via Context Menu, obviously.
Welcome all critiques of this answer, and will immediately take it down if it’s not “on the mark.”