如何解决WinForm 程序中由于拖拽导致MouseUp事件无法触发的问题

sorry_rr 2010-11-16 10:22:51
RT
...全文
442 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
sorry_rr 2010-11-16
  • 打赏
  • 举报
回复
我那些按钮是动态添加的、事件也是。这有影响吗?
sorry_rr 2010-11-16
  • 打赏
  • 举报
回复
(T_T)为什么在我测试的那个项目就行。在我正式的那个项目就不行
获取的坐标是相对的还是绝对的?
IT修补匠 2010-11-16
  • 打赏
  • 举报
回复
为什么会无法触发啊!
sorry_rr 2010-11-16
  • 打赏
  • 举报
回复
好像可以。我测试一下先待会结贴
(^_^)谢谢
bloodish 2010-11-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sorry_rr 的回复:]
OnMouseUp(myTextBox, new MouseEventArgs(Control.MouseButtons, 0, Control.MousePosition.X, Control.MousePosition.Y, 0));
这个这么多参数。是自定义的吗?
[/Quote]
OnMouseUp是myTextBox的MouseUp事件对应的方法,

myTextBox 是你想要触发MouseUp事件的控件,其他都是系统的参数
sorry_rr 2010-11-16
  • 打赏
  • 举报
回复
OnMouseUp(myTextBox, new MouseEventArgs(Control.MouseButtons, 0, Control.MousePosition.X, Control.MousePosition.Y, 0));
这个这么多参数。是自定义的吗?

bloodish 2010-11-16
  • 打赏
  • 举报
回复
要想办法自己去触发MouseUp事件.

在QueryContinueDrag事件中可以这样处理:


Rectangle rect = myTextBox.Bounds;
if (Control.MouseButtons != MouseButtons.Left && !rect.Contains(PointToClient(Control.MousePosition)))
{
e.Action = DragAction.Cancel;
OnMouseUp(myTextBox, new MouseEventArgs(Control.MouseButtons, 0, Control.MousePosition.X, Control.MousePosition.Y, 0));
}

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧