blah blah blah is here! blah blah » Close
I want to assign a string the contents of a richtextbox up until the point that the user has selected. Is there a way to do this?
Yes, you can use the textbox' SelectedText property//Gets the selected text from textBox1string selected = textBox1.SelectedText;Hope this helps
answered 2 years ago by:
I think the OP means that he wants to capture the text <i>before</i> the selection. If that's the case, the code would be:int index = richTextBox1.SelectionStart;string priorToSelected = richTextBox1.Text.Substring(0, index);
I see :)
Thanks!
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!
Got feedack? Found a bug? report it here.
1 answers
Yes, you can use the textbox' SelectedText property
//Gets the selected text from textBox1
string selected = textBox1.SelectedText;
Hope this helps
answered 2 years ago by:
2499
I think the OP means that he wants to capture the text <i>before</i> the selection. If that's the case, the code would be:
int index = richTextBox1.SelectionStart;
string priorToSelected = richTextBox1.Text.Substring(0, index);
answered 2 years ago by:
17279
I see :)
answered 2 years ago by:
2499
Thanks!
answered 2 years ago by:
51
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!