Reputation: 763
I have a richtextbox which I want to limit to bulletins, numbering, arial size 10, underline, bold, italic.
Nothing else is to be possible. The issue takes place when a user would paste something into the textbox. Background colors, pictures, etc etc would then be pasted into the textbox.
Pasting still needs to be possible. But we only want to keep bulletins, numbering, underline, bold and italic.
How do we remedy this?
Upvotes: 1
Views: 571
Reputation: 81243
You can hook the event for disabling the paste operation in case DataObject is not of type text
. This is what you looking for, replace textBox instance with your richTextBox instance in this sample - Disable paste opeartion on textBox if not text is copied
Upvotes: 0
Reputation: 10244
You'd have to intercept the Pasted
event and strip everything except text out. Depending what format the pasted data is in you might need a parsing library like the HTML Agility Pack.
Upvotes: 1