Forum guidelines
  • Home
  • »
  • C# Language
  • »
  • How to get deselect text from a full text in a combobox
AuthorQuestion
How to get deselect text from a full text in a combobox
Posted By Sayed Hassan on 24 Apr 2013
I need to get read a deselect text from a full text in a combobox where some text are highlighted.
Suppose the searching text is emergency where emer is not highlighted but gency is highlighted.
Now I want to read this deselect text emer to perform operation.
 
textbox1: emergency (at typing)

textbox2.Text = textbox1.Text.Substring(textbox1.SelectionStart, textbox1.SelectionLength);

I am trying this code variously. But it's not working.

Help me plz.Thanks in advance.

AuthorReply
Re: How to get deselect text from a full text in a combobox
Posted By Vulpes on 24 Apr 2013  
Try:

textbox2.Text = textbox1.Text.Substring(0, textbox1.SelectionStart);


Re: How to get deselect text from a full text in a combobox
Posted By Javeed M Shaikh on 24 Apr 2013  
assuming the not selected text is in the beginning:

string notselected = textBox1.Text.Substring(0, textBox1.Text.Length - textBox1.SelectionLength);

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.