本文介绍了C#我有一个带背景图片的按钮。如何在一定条件下触发mouseleave事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带背景的按钮。我创建了mouseenter& mouseleave事件。在mouseleave事件中,如果鼠标光标在2个坐标之外,它将触发mouseleave事件。
我的问题是当我离开500X250矩形时,它会触发mouseleave。我希望它能在250X125矩形中触发。
我尝试过:
I have a button with a background. I created mouseenter & mouseleave event. In the mouseleave event, if a mouse cursor is outside of 2 coordinates it will trigger the mouseleave event.
my problem is when i leave in 500X250 rectangle, it will trigger the mouseleave. i want it to trigger in 250X125 rectangle.
What I have tried:
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);
}
推荐答案
这篇关于C#我有一个带背景图片的按钮。如何在一定条件下触发mouseleave事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!