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)

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)

Hope that helps.


Edited 6 Years Ago by farooqaaa: n/a

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.


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.


Edited 6 Years Ago by __avd: Email Snipped.

This question has already been answered. Start a new discussion instead.