Search code examples
c#richtextboxselectedtext

How to read selected text on richTextBox?


There is a richTextBox that has string. I want to select a few characters on the richTexBox by mouse and save them in a variable. I use this method:

richTextBox1.SelectedRtf;

It shows me selected characters but is has some additional string and i don't want them. How can I remove them?

This is additional string: {\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1065\uc1 }


Solution

  • try

     richTextBox1.SelectedText
    

    Here is the msdn link for more information
    http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.selectedtext(v=vs.110).aspx