动态创建按钮上的VB.NET右键单击事件

时间:2013-02-27 15:35:40

标签: vb.net events

类似于:Get the ID/Name of a button in a click event. VB.NET

我想查找是否在鼠标上单击了左键或右键。我已经声明了一个包含按钮的块类。我已经为点击按钮分配了一个事件:

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

这样可以正常工作,但是当我尝试选择正确的按钮时,请单击:

    If e.Button = MouseButtons.Right Then
        MessageBox.Show("RH click")
    Else
        button.Text = text
        button.BackColor = Color.LightGray
    End If

它抱怨e.Button:      Button不是System.EventArgs

的成员

有什么想法吗?

1 个答案:

答案 0 :(得分:4)

处理MouseUpMouseDown事件。他们通过了MouseEventArgs