0

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

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by ch_shoukat222
1

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

Edited by farooqaaa: n/a

0

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!

Edited by __avd: Email Snipped.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.