C#失去焦点触发事件:
textBox5.LostFocus+=newEventHandler(txt_LostFocus);//失去焦点后发生事件
textBox5.GotFocus+=newEventHandler(txt_GotFocus);//获取焦点前发生事件
textBox5.MouseClick+=newMouseEventHandler(textBox5_MouseClick);//鼠标点击事件
newEventHandler(txt_LostFocus);
voidtxt_LostFocus(objectsender,EventArgse)
{
txtInput(textBox5);
}
扩展资料
C#WinForm窗体获得焦点时即触发事情
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWindowsApplication3
{
publicpartialclassForm1:Form
{
publicForm1()
{
InitializeComponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
Form2obj=newForm2(this.label1);
obj.Show();
}
}
}
{
InitializeComponent();
textBox1.Enter += new EventHandler(textBox1_Enter); //获得焦点事件
textBox1.Leave += new EventHandler(textBox1_Leave); //失去焦点事件。
}
void textBox1_Enter(object sender, EventArgs e)
{
MessageBox.Show("获得了焦点");
}
void textBox1_Leave(object sender, EventArgs e)
{
MessageBox.Show("失去了焦点");
}
textbox.Attributes["onfocus"]="Check(this.value)";
textbox.Attributes["onblur"]="Msg(this.value)";
在.aspx页面上添加客户端事件
function Check(val) {
//to do something
}
function Msg(val) {
alert(val);
}
失去焦点: onblur="SetValue(this)"
CheckValue(this) 和 SetValue(this)用JS写的函数
*Blur。。。什么的是失去焦点
textbox控件f开头的事件只有fontchang forecolorchanged