我想TextBox在它有焦点的时候为它添加一个偶数.我知道我可以用一个简单的方法做这个textbox1.Focus并检查bool值...但我不想这样做.
我想这样做:
this.tGID.Focus += new System.EventHandler(this.tGID_Focus);
Run Code Online (Sandbox Code Playgroud)
我不确定EventHandler是否是正确的方法,但我知道这不起作用.
lor*_*eto 17
您正在寻找GotFocus活动.还有一个LostFocus事件.
textBox1.GotFocus += textBox1_GotFocus;
Run Code Online (Sandbox Code Playgroud)
Mic*_*ray 14
this.tGID.GotFocus += OnFocus;
this.tGID.LostFocus += OnDefocus;
private void OnFocus(object sender, EventArgs e)
{
MessageBox.Show("Got focus.");
}
private void OnDefocus(object sender, EventArgs e)
{
MessageBox.Show("Lost focus.");
}
Run Code Online (Sandbox Code Playgroud)
这应该做你想要的,本文描述了被调用的不同事件和顺序.你可能会看到更好的事件.
我对汉斯帕森特的评论进行了投票,但这确实应该是一个答案.我正在使用3.5 .NET环境中的Telerik UI,并且RadTextBoxControl上没有GotFocus事件.我不得不使用Enter事件.
textBox1.Enter += textBox1_Enter;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
49780 次 |
| 最近记录: |