how to put focus on TextBox when the form load?

前端 未结 16 1191
清歌不尽
清歌不尽 2020-12-04 14:59

I have in my C# program textBox

I need that when the program start, the focus will be on the textBox

I try this on Form_Load:

MyTextBox.Focus         


        
16条回答
  •  清歌不尽
    2020-12-04 15:24

    Set Tabstop to True and TabIndex to the minimum to the control on which you need focus.

    e.g. If you have 2 TextBoxes : TextBox1 and TextBox2, set Tabstop to True for both and TabIndex to 0 and 1 respectively. When the form loads, the focus will be on TextBox1 and on the press of 'Tab' key, the focus will move to TextBox2.

提交回复
热议问题