How do you get the control that was clicked to open a ContextMenuStrip?

前端 未结 5 507
醉梦人生
醉梦人生 2020-12-16 18:47

I\'m using a ContextMenuStrip for multiple controls and I\'m trying to figure out the best way to get the control that was actually clicked on to open the Conte

5条回答
  •  失恋的感觉
    2020-12-16 19:35

    Private Sub mnuWebCopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuWebCopy.Click
    
    Dim myItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem)
    Dim cms As ContextMenuStrip = CType(myItem.Owner, ContextMenuStrip)
    
    MessageBox.Show(cms.SourceControl.Name)
    
    End Sub
    

提交回复
热议问题