如果鼠标右键被按下,下列代码将显示特定的 弹出式菜单:
C# | 复制代码 |
---|---|
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if(e.Button == MouseButtons.Right) popupMenu1.ShowPopup(Control.MousePosition); } |
Visual Basic | 复制代码 |
---|---|
Private Sub Form1_MouseUp(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp If e.Button = MouseButtons.Right Then PopupMenu1.ShowPopup(Control.MousePosition) End If End Sub |