MouseLeave未触发C#WinForms [英] MouseLeave not fired C# WinForms
本文介绍了MouseLeave未触发C#WinForms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有2个按钮的用户控件,只有当鼠标位于控件区域内时,该控件才可见.
I have a user control with 2 buttons, that should only be visible when the mouse is inside the area of the control.
我正在显示这样的按钮:
I'm showing the buttons like this:
private void Node_MouseEnter(object sender, EventArgs e)
{
btn1.Show();
btn2.Show();
}
并像这样隐藏:
protected override void OnMouseLeave(EventArgs e)
{
if (this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition)))
return;
else base.OnMouseLeave(e);
}
private void Node_MouseLeave(object sender, EventArgs e)
{
btn1.Hide();
btn2.Hide();
}
问题在于,有时(随机情况下)不会触发MouseLeave
事件,并且即使鼠标位于控件之外,按钮仍保持可见.
The problem is that sometimes (random situations) the MouseLeave
event is not fired, and the buttons stay visible, even with the mouse outside the control.
是否有可能多个事件发生冲突?
Is it possible that multiple events get in conflict ?
推荐答案
查看全文