如何在Visual Studio中检测右键点击事件? [英] How to detect a Right Click event in Visual studio?

查看:211
本文介绍了如何在Visual Studio中检测右键点击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这应该是一个简单的问题,但我在编程方面还是比较新的,而我的生活中我无法想出如何使用右键单击事件。所有我想要做的是调用一个事件,当我右键单击一个图片框。它不在事件工具栏,我觉得像一个真正的白痴。任何帮助将不胜感激。我正在运行2010版本。

解决方案

您可以使用mouse_down事件并检查是否右键单击



  Private Sub PictureBox1_MouseDown(Byval sender As Object,Byval e As System.Windows.Forms.MouseEventArgs)Handles PictureBox1.MouseDown 

如果e.Button = MouseButtons.Right Then
MsgBox(Right Button Clicked)
如果

End Sub

参考这个 http://www.homeandlearn.co.uk/net/nets10p2.html


Okay, so this should be a simple question, but I'm fairly new at programming, and I can't for the life of me figure out how to use a right-click event. All I want to do is call an event that does something when I right-click a picturebox. It's not in the events toolbar, and I feel like a real idiot. Any help would be greatly appreciated. I'm running the 2010 version.

解决方案

You can use the mouse_down event and check if it is a right-click

Private Sub PictureBox1_MouseDown(Byval sender As Object, Byval e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown

    If e.Button = MouseButtons.Right Then
        MsgBox("Right Button Clicked")
    End If

End Sub

refer to this http://www.homeandlearn.co.uk/net/nets10p2.html

这篇关于如何在Visual Studio中检测右键点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆