【发布时间】:2018-06-15 07:42:11
【问题描述】:
我目前正在开发 WinForms NumericUpDown 控件的子类。但是因为他们构建了它,所以它包含多个子控件,它弄乱了 MouseLeave 和 MouseEnter 事件。
当鼠标移入控件边界时,当鼠标移过其中一个子控件(例如向上和向下箭头按钮)时,将触发 MouseEnter,然后触发 MouseExit。除此之外,MouseExit 有时根本不会触发,尤其是在快速将鼠标移出控制范围时...
如何让事件正确触发或解决此问题?
编辑:
这是一个简单的代码示例:
public class TMNumericUpDownControl : NumericUpDown
{
public TMNumericUpDownControl()
{
MouseEnter += MouseEnterHandler;
MouseLeave += MouseLeaveHandler;
}
private void MouseEnterHandler(object sender, EventArgs e)
{
Debug.WriteLine("entered");
}
private void MouseLeaveHandler(object sender, EventArgs e)
{
Debug.WriteLine("Left");
}
}
【问题讨论】:
-
你有任何代码试验吗?
-
已将其添加到问题中。
标签: c# winforms events numericupdown