简体   繁体   English

C#Winforms与DoubleClick事件和MouseDoubleClick事件之间存在差异

[英]C# Winforms difference between DoubleClick event and MouseDoubleClick event

Quick question here: As the title says, what's the difference between the two events? 这里的快速问题:正如标题所说,这两个事件之间的区别是什么?

As far as I can tell, MouseDoubleClick is inherited from Control , while DoubleClick is inherited from Component , but is there any functional difference between the two? 据我所知, MouseDoubleClick继承自Control ,而DoubleClick继承自Component ,但两者之间是否有任何功能差异?

Thanks 谢谢

From the MSDN Documentation : MSDN文档

DoubleClick events are logically higher-level events of a control. DoubleClick事件是控件的逻辑上更高级别的事件。 They may be raised by other user actions, such as shortcut key combinations. 它们可能由其他用户操作引发,例如快捷键组合。

As you can see here: Control.MouseDoubleClick Event 正如您在此处看到的: Control.MouseDoubleClick事件

The following series of events is raised by the control when such a user action takes place: 当发生此类用户操作时,控件将引发以下一系列事件:

MouseDown event. MouseDown事件。

Click event. 点击活动。

MouseClick event. MouseClick事件。

MouseUp event. MouseUp事件。

MouseDown event. MouseDown事件。

DoubleClick event. DoubleClick活动。

MouseDoubleClick event. MouseDoubleClick事件。

MouseUp event. MouseUp事件。

so there is a difference between the two as the MouseDoubleClick implies all these events to get triggered. 所以两者之间存在差异,因为MouseDoubleClick意味着要触发所有这些事件。

I believe the key difference between these two is the event handler where the "DoubleClick" event will include a simple EventArgs object while the "MouseDoubleClick" will include a MouseEventArgs which will include the position of the mouse among other things. 我相信这两者之间的关键区别在于事件处理程序,其中“DoubleClick”事件将包含一个简单的EventArgs对象,而“MouseDoubleClick”将包含一个MouseEventArgs,其中包括鼠标的位置等。

So basically if you need to know where the click occurred on the control, I would favor "MouseDoubleClick" over "DoubleClick". 所以基本上如果你需要知道控件上的点击发生在哪里,我会赞成“MouseDoubleClick”而不是“DoubleClick”。

DoubleClick 的DoubleClick

private void DoubleClick_Event(object sender, EventArgs e)

MouseDoubleClick MouseDoubleClick

private void MouseDoubleClick_Event(object sender, MouseEventArgs e)

explain how these two pages and the differences between the two events 解释这两个页面如何和两个事件之间的差异

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doubleclick.aspx http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doubleclick.aspx

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousedoubleclick.aspx http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousedoubleclick.aspx

A double-click is determined by the mouse settings of the user's operating system. 双击由用户操作系统的鼠标设置决定。

The MouseDoubleClick event occurs when the user depresses a mouse button twice in quick succession when the cursor is over the control. 当用户在光标位于控件上时快速连续按下两次鼠标按钮时,会发生MouseDoubleClick事件。

Regards. 问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM