Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

easy question ?

Status
Not open for further replies.

ostelen

Programmer
Jan 30, 2005
5
FR
Hello,

I am building a software in WinForm C#.

When the window is opening, the cursor of the mouse should be placed in the textBox1.

This is the code i am using when the windows is opening, but it doesnt work:
textBox1.TabIndex = 0;
textBox1.Select(0,0);
textBox1.Focus();

The cursor is not in the textbox1, so i have to press the button "TAB" each time the window is opening to be able to enter my text :(

Does someone have an idea ?

Thx
 
What event are you putting the above code into?

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
you need to set the tab order for the form so that the text box is number 0.

click view->tab order from the menu and click on the controls in the order you want the form to prompt for them in.

good luck,


mr s. <;)

 
put the code in
private void Form1_Load(object sender, System.EventArgs e)
{
}

 
Thx

I found the soluce

The problem was that my textbox1 was inside a groupbox !

I push the textbox out, now it is working

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top