WinForm The default focus setting of the text box after the window is opened, the default focusing to a text box after entering the window, two methods:
① setting TabIndex
Set the TabIndex in the text box property to 0, and the focus is in this text box by default.
②winform's Activated Event
You can get focus by adding textbox1.focus () to the activated event of the form.
Private void Form1_activated (object sender, EventArgs e) { textbox1.focus ();} /* */
Http://www.cnblogs.com/roucheng/p/3518068.html
A textbox can have focus. There are several prerequisites:
1. The form to which the textbox belongs (form) is in the operational (active) state. That is, the user selects the form.
2. The Enable property of the TextBox, the Visiable property is true.
Initially thought to add Textbox1.focus () in the form's Load event, the test failed
private void Form1_Load (object sender, EventArgs e)
{
Textbox1.focus ();
}
Since the focus () function is called when the form is loaded, the TextBox has not been successfully displayed to the interface. So it leads to failure.
I test: The author has always been in the Load event to specify the control focus, the effect is not ideal, I did not think because the Load event when the control was not created, so the input focus cannot be set.
Recommendation: http://www.cnblogs.com/roucheng/p/3509606.html
WinForm Setting Control focus