
C#如何在Form启动时控制焦点落在某一个控件上?
load方法试了不管用啊。我的意思是使某控件表现为被鼠标点过的样子,比如button点过后会出现一个蓝框,combobox点过后文字会被全选。...
load方法试了不管用啊。我的意思是使某控件表现为被鼠标点过的样子,比如button点过后会出现一个蓝框, combobox点过后文字会被全选。
展开
6个回答
展开全部
你可以在Load的方法中调用某一个控件的Focus方法 即可转移焦点
但是容器控件是不可以有焦点的,比如Panel
但是容器控件是不可以有焦点的,比如Panel
展开全部
load 不行那就写在form_active里!不过窗体每次激活一下都会执行一下
this.comboBox1.SelectAll();
或者
this.comboBox1.Focus();
this.comboBox1.SelectionStart = 0;
this.comboBox1.SelectionLength = this.comboBox1.Text.Length;
this.comboBox1.SelectAll();
或者
this.comboBox1.Focus();
this.comboBox1.SelectionStart = 0;
this.comboBox1.SelectionLength = this.comboBox1.Text.Length;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
应该是Load事件,如:
//this.Load += new System.EventHandler(this.Form1_Load);
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.Focus() ;
}
//this.Load += new System.EventHandler(this.Form1_Load);
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.Focus() ;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
page.ClientScript.RegisterStartupScript(page.GetType(), "txtName", "<script>document.forms(0)." + str_Ctr_Name + ".focus();document.forms(0)." + str_Ctr_Name + ".select();</script>");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Form_Load函数里面加上
this.button1.Focus();
this.button1.Focus();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
botton1.Focus();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询