[英]How to find a right click event on MouseUp anywhere on the form?
I need to catch the MouseUp on right click anywhere on the form. 我需要右键单击窗体上的任意位置来捕获MouseUp。 I understand how to create custom event to handle the right click event on individual controls, but having issues with catching it regardless of where the right click happens;
我了解如何创建自定义事件来处理单个控件上的右键单击事件,但是无论右键单击发生在何处,捕获它都有问题; over a control or even in a blank space on the form.
控件上,甚至窗体上的空白中。
So as stated, I understand how to catch the right click per individual controls: 因此,如前所述,我了解了如何在各个控件上获得正确的点击:
this.myButton.MouseUp += new MouseEventHandler(this.myButton_MouseUpToGetHelpText);
private void myButton_MouseUpToGetHelpText(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
// Logic here
}
}
Just not quite sure how to listen for an event on the whole form. 只是不太确定如何从整体上监听事件。 Any thoughts/suggestions appreciated.
任何想法/建议表示赞赏。
Simple: 简单:
this.MouseUp += new MouseEventHandler(this.form_MouseUpToGetHelpText);
private void form_MouseUpToGetHelpText(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
// Logic here
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.