CONTEXTMENU

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stever1975

    CONTEXTMENU

    I know how to add menuitems: contextMenu1.Me nuItems.Add(men uItem1)
    But how do you put an event handler at the level of contextmenu that
    which tells you which item has been clicked.
    The reason I want to this is a want to link all the menuitems to the
    same function, and that function is going to take menuitem.text as a
    parameter.

    thanks
    Steve
  • kimiraikkonen

    #2
    Re: CONTEXTMENU

    On Apr 20, 7:46 pm, Stever1975 <Stever1...@gma il.comwrote:
    I know how to add menuitems: contextMenu1.Me nuItems.Add(men uItem1)
    But how do you put an event handler at the level of contextmenu that
    which tells you which item has been clicked.
    The reason I want to this is a want to link all the menuitems to the
    same function, and that function is going to take menuitem.text as a
    parameter.
    >
    thanks
    Steve
    If i understood correctly, that must be what you're looking for:

    Private Sub ContextMenuStri p1_itemclick(By Val sender As System.Object,
    ByVal e As System.Windows. Forms.ToolStrip ItemClickedEven tArgs) Handles
    ContextMenuStri p1.ItemClicked
    MsgBox(e.Clicke dItem.Name.ToSt ring)
    End Sub

    HTH,

    Onur

    Comment

    • kimiraikkonen

      #3
      Re: CONTEXTMENU

      On Apr 20, 7:55 pm, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
      On Apr 20, 7:46 pm, Stever1975 <Stever1...@gma il.comwrote:
      >
      I know how to add menuitems: contextMenu1.Me nuItems.Add(men uItem1)
      But how do you put an event handler at the level of contextmenu that
      which tells you which item has been clicked.
      The reason I want to this is a want to link all the menuitems to the
      same function, and that function is going to take menuitem.text as a
      parameter.
      >
      thanks
      Steve
      >
      If i understood correctly, that must be what you're looking for:
      >
      Private Sub ContextMenuStri p1_itemclick(By Val sender As System.Object,
      ByVal e As System.Windows. Forms.ToolStrip ItemClickedEven tArgs) Handles
      ContextMenuStri p1.ItemClicked
      MsgBox(e.Clicke dItem.Name.ToSt ring)
      End Sub
      >
      HTH,
      >
      Onur
      Adiitionaly,

      Or you may want to get item's text instead of item's name, then do
      this;

      Private Sub ContextMenuStri p1_itemclick(By Val sender As System.Object,
      ByVal e As System.Windows. Forms.ToolStrip ItemClickedEven tArgs) Handles
      ContextMenuStri p1.ItemClicked
      MsgBox(e.Clicke dItem.Text.ToSt ring)
      End Sub

      Hope this helps,

      Onur

      Comment

      Working...