文本框焦点问题C# [英] Textbox focus problem C#
问题描述
当我放置断点然后焦点设置正确--- txtGrpLCode.Text(这是正确的)
但是正常运行然后焦点设置--- txtSrNo.text(这是错误的)
请帮助....
提示..
如果我的数据gride启用false然后工作确定
但我不会使datagride启用true
我尝试了什么:
插入记录后
....
txtGrpLCode.Text =;
txtSrNo.Text =;
txtTag.Text =;
txtGrpLCode.Focus();
使用:txtGrpLCode.Select();
txtGrpLCode.Focus();另外,尝试在设计时更改控件的TabOrder;或者,在运行时,使用'SendToBack,或'RoundToFront。
也尝试:this .ActiveControl = txtGrpLCode;
如果这些都不起作用,则需要显示更多代码。
最终使用此。 ..
private void txtSrNo_Enter(object sender,EventArgs e)
{
if(txtGrpLCode.Text.ToString()。Trim() .Length == 0)
txtGrpLCode.Focus();
}
When i Put breakpoint then Focus set correctly ---txtGrpLCode.Text (that is Right)
but normaly run then focus set ---txtSrNo.text (That is wrong)
Pls Help....
Hint..
If my datagride enable false then Work Ok
But i wont datagride enable true
What I have tried:
after insert record ....
txtGrpLCode.Text = "";
txtSrNo.Text = "";
txtTag.Text = "";
txtGrpLCode.Focus();
Use:txtGrpLCode.Select(); txtGrpLCode.Focus();Also, try changing the TabOrder of your Controls at design-time; or, at run-time, by using 'SendToBack, or'BringToFront.
Also try:this.ActiveControl = txtGrpLCode;
If none of these work, you need to show more of your code.
Final Use This ...
private void txtSrNo_Enter(object sender, EventArgs e)
{
if (txtGrpLCode.Text.ToString().Trim().Length == 0)
txtGrpLCode.Focus();
}
这篇关于文本框焦点问题C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!