[英]Why is the button click event not fired after textbox leave event?
I have text box with leave event 我有留言活动的文本框
private void textBox1_Leave(object sender, EventArgs e)
{
MessageBox.Show("Leave");
}
and button with click event 和点击事件按钮
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Click");
}
When I enter text in textbox and click the button the leave event fires but click event does not. 当我在文本框中输入文本并单击按钮时,将触发leave事件,但click事件不会触发。
How do I fire the click event without invoking button1_Click
in the leave event? 如何在不调用leave事件中的
button1_Click
情况下触发click事件?
Simply replace MessageBox.Show
with Console.WriteLine
in the textBox1_Leave
and you will see the button's click event. 只需将
MessageBox.Show
替换为textBox1_Leave
Console.WriteLine
,您将看到该按钮的click事件。 In other words, it seems that user interaction in the Leave
event breaks events chain, because of the focus was captured by MessageBox
. 换句话说,似乎
Leave
事件中的用户交互会破坏事件链,因为MessageBox
捕获了焦点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.