C# 坐标 动态添加鼠标滑过事件
- 提问者网友:残阳碧曼
- 2021-02-11 01:15
- 二级知识专家网友:悲观垃圾
- 2021-02-11 01:37
- 1楼网友:年轻没有失败
- 2021-02-11 02:52
要知道鼠标的坐标是x,y两个值
你存的话也要存两个 存一个无意义
代码:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms;
namespace winform_test_02 { public partial class form1 : form { public form1() { initializecomponent(); } int x1, y1, x2, y2, x3, y3, x4, y4,count = 0; private void form1_mouseclick(object sender, mouseeventargs e) { switch (count) { case 0://count = 0;第一次点击时赋值 x1 = e.x; y1 = e.y; break; case 1://count = 0;第二次点击时赋值 x2 = e.x; y2 = e.y; break; case 2://count = 0;第三次点击时赋值 x3 = e.x; y3 = e.y; break; case 3://count = 0;第四次点击时赋值 x4 = e.x; y4 = e.y; break; default://超出四次 不做记录 return; } count++;//记录点击次数 } } }
你可以加一句messagebox.show() 来判断下是否正确
本人测试无问题