Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How Can I search and highlight texts in TextBox???
I don't wanna use RichTextBox.
Posted

Textboxes do not have highlight formatting, the best you can do is Select text.
http://msdn.microsoft.com/en-us/library/hk09zy8f.aspx[^]
 
Share this answer
 
Comments
Espen Harlinn 4-Sep-12 8:30am    
5'ed!
Mehdi Gholam 4-Sep-12 8:31am    
Cheers Espen!
You may use this snippet, which finds a text from textBox1 inside TextBox2 by clicking on a button:
C#
private void button1_Click(object sender, EventArgs e)
{
   int idx = textBox2.Text.IndexOf(TextBox1.Text);
   if (idx >= 0)
   {
      textBox2.SelectionStart = idx;
      textBox2.SelectionLength = TextBox1.Text.Length;
      textBox2.Focus();
   }
}
 
Share this answer
 
Comments
samanq 4-Sep-12 5:42am    
Thank you. It worked :)
Espen Harlinn 4-Sep-12 8:29am    
5'ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900