hi there,
how can i select the text in a textbox when i use the tab key or when i click the mouse on the textbox. how can i do this in C# VS 2008 standard edition.
thank you in advance
hi there,
how can i select the text in a textbox when i use the tab key or when i click the mouse on the textbox. how can i do this in C# VS 2008 standard edition.
thank you in advance
To select the text of a TextBox when it is activated by Tab key. Then add "Enter" event for the textbox and use this code:
private void textBox1_Enter(object sender, EventArgs e)
{
textBox1.SelectAll();
}
And to select the text when the textBox is clicked then add a "Click" event and use the same code (as above):
private void textBox1_Click(object sender, EventArgs e)
{
textBox1.SelectAll();
}
Hope that helps.
Thanks
when you are running the program the text box is automatically selected when you focus on it through tab.
but if you want to select it by automatically while form load then you sould add this code in form load event.
textbox1.select();
or
textbox1.selectall();
it is a built in function to select the text in text box.
i hope it will help you if not then contact me at my mail address.
...
GOOD LUCK!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.