A short help for you to select and highlight some part of the total text of a textbox. Instructions for this are as follows
Instructions:
- Open Visual Studio and Create a New project.
- In the new project, you will be having a form.
- Insert two textboxes onto that form.
- First textbox will be having a lot of text from which we select just a part of the whole text of that control which was given by second textbox.
- Add a button and Change its Text to “Find Text”.
- Double Click on the button and add the following code in button_click event.
textBox1.Select(textBox1.Text.IndexOf(textBox2.Text), textBox2.Text.Length);
textBox1.Focus(); - Run the program.
- Enter a line of text in first textbox and a part of that line in 2nd textbox.
- Hit the button and desired text got highlighted in first textbox.
Incoming search terms:
- How select particular word select and store In length input textbox at asp net (1)