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!
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You can also use
There is a very simple way to do this that is working well for me:
Since the
Text
property is inherently without formatting resetting the RTF text then setting the text property to the raw input removes any of the special items that may have been pasted in.Simple, but everything in the clipboard is in plain text when application is open.
My solution
I achieved this by udpating the font and colour for the whole RTB when its contents are changed. This works fine for me as the entry box does not need to deal with huge amounts of text.
The answer from pasztorpisti worked like a charm for me. Since I'm using vb.net I thought I'd post my translated code for others: