c#窗体启动的时候如何把焦点设在textbox2上?

textBox2.Focus();不行啊

//============ 方法1 =========
你只要 在 把 textBox2.TabIndex = 0; 就OK了!

private void Form1_Load(object sender, EventArgs e)
{
textBox2.TabIndex = 0;
}

//============ 方法2 =========
ActiveControl = textBox2;
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-12-06
正解是,在窗体Activated事件中这样写
private void test_Activated(object sender, EventArgs e)
{
this.textBox1.Focus();
}
第2个回答  2012-12-06
this.textBox2.parent.select();
this.textBox2.select();
this.textBox2.focus();
第3个回答  推荐于2018-04-21
private void Form1_Load(object sender, EventArgs e)
{
ActiveControl = textBox2;
}本回答被提问者和网友采纳
相似回答