简体   繁体   English

C#中的事件处理

[英]Event handling in C#

I am trying to design a windows form application. 我正在尝试设计Windows窗体应用程序。 Now I have written an event handler for a button object to handle the Button.Click event. 现在,我为按钮对象编写了一个事件处理程序,以处理Button.Click事件。 It worked fine until I wrote another event handler for Button.MouseDown to capture both left and right mouse clicks, in which case the only code that worked was the one for Mouse.ButtonDown. 在我为Button.MouseDown编写另一个事件处理程序以捕获左右鼠标单击事件之前,它一直工作良好,在这种情况下,唯一起作用的代码是Mouse.ButtonDown的代码。 I understand that I can make the previous code work by copying the code from Button.Click to the section in MouseButtonDown that responds to left click. 我了解可以通过将Button.Click中的代码复制到MouseButtonDown中响应左键单击的部分来使先前的代码正常工作。 My question is that are there any event handlers that take precedence over others and if yes, in what order? 我的问题是,是否有任何事件处理程序优先于其他事件处理程序,如果是,则按什么顺序进行? Another thing that intrigues me is that are there any more event handlers that are ambiguous? 令我着迷的另一件事是,还有更多不确定的事件处理程序吗?

Here you got a detailed list of the mouse events and what they do in windows forms. 在这里,您可以获得鼠标事件的详细列表以及它们在Windows窗体中的作用。

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

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