VB.NET 动态创建按钮上的右键单击事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15116020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VB.NET right button click event on dynamically created button
提问by pluke
Similar to: Get the ID/Name of a button in a click event. VB.NET?
I am looking to find whether the left or right button was clicked on a mouse. I have declared a block class which holds buttons. I've assigned an event to the button click through:
我正在寻找是在鼠标上单击了左键还是右键。我已经声明了一个包含按钮的块类。我已经为按钮点击分配了一个事件:
Class Block
Public X As Integer
Public Y As Integer
Public type As String
Public status As String
Public text As String
Public WithEvents button As Button
Private Sub btnReveal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.Click
....
....
End Sub
This works fine, but when I try to pick up the right button click using:
这工作正常,但是当我尝试使用右键单击时:
If e.Button = MouseButtons.Right Then
MessageBox.Show("RH click")
Else
button.Text = text
button.BackColor = Color.LightGray
End If
It complains on e.Button: Button is not a member of System.EventArgs
它抱怨 e.Button: Button is not a member of System.EventArgs
Any ideas?
有任何想法吗?

