I have created a new component which inherits from the UserControl class so it already has a ContextMenuStrip property inherited. However since my component consists of a textbox and two buttons, how can I make this contextmenu show when anything inside the component in clicked (show the menu when I right click the buttons or the textbox). Currently It will bring up the contextmenu of the control which I have clicked. So if I click the textbox I get the native Cut, Copy, Paste menu instead of the one I initialized in my component class.
I have also tried this:
But does not work as the class consists of multiple components (textbox and two buttons).
I have also tried this:
VB.NET:
Private Sub ShowContextMenu(ByVal sender As Object, ByVal e As MouseEventArgs) Me.MouseClick
If e.Button = Windows.Forms.MouseButtons.Right Then
If Me.ContextMenuStrip IsNot Nothing Then
Me.ContextMenuStrip.Show(Me, e.Location)
End If
End If
End Sub
But does not work as the class consists of multiple components (textbox and two buttons).