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

前端 未结 5 497
醉梦人生
醉梦人生 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:26

    On VB.NET 2013 this work so fine:

    Dim cms As ContextMenuStrip = CType(sender, ContextMenuStrip)
    MessageBox.Show(cms.SourceControl.Name)
    

提交回复
热议问题