【发布时间】:2016-05-12 21:38:05
【问题描述】:
我有一个带背景的按钮。我创建了 mouseenter & mouseleave 事件。在 mouseleave 事件中,如果鼠标光标在 2 个坐标之外,则会触发 mouseleave 事件。
private void Button_SpanMouseEnter(object sender, EventArgs e)
{
Button x = sender as Button;
x.Size = new Size(500, 250);
x.Location = new Point(0, 0);
}
private void Button_SpanMouseLeave(object sender, EventArgs e)
{
Button x = sender as Button;
//If cursor is outside of this coordinates(0,0) & (250,125)
//it will trigger this size
x.Size = new Size(250,125);
x.Location = new Point(0, 0);
}
我的问题是当我离开 500X250 矩形时,它会触发鼠标离开。我希望它在 250X125 矩形中触发。
【问题讨论】:
-
如果不在预期边界内,您可以处理 MouseLeave 并返回