Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to get item clicked event for ContextMenus Dropdown item clicked

How to get item clicked event for ContextMenus Dropdown item clicked

Scheduled Pinned Locked Moved C#
data-structurestutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AhmedMasum
    wrote on last edited by
    #1

    ToolStripMenuItem firstItem = new ToolStripMenuItem("level1); for (int i = 0; i **in the above code centertable is a string array. I am adding the element of this array as sub menu/dropdown item for level1. Now I need the following task: 1. No need to get the level1 selected item 2. need to handle the submenu seleted event 2. Need to get the sub menu/ dropdownitems that have been selected How can I do that...**

    S 1 Reply Last reply
    0
    • A AhmedMasum

      ToolStripMenuItem firstItem = new ToolStripMenuItem("level1); for (int i = 0; i **in the above code centertable is a string array. I am adding the element of this array as sub menu/dropdown item for level1. Now I need the following task: 1. No need to get the level1 selected item 2. need to handle the submenu seleted event 2. Need to get the sub menu/ dropdownitems that have been selected How can I do that...**

      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      1st.: Don't add event on top level item 2nd: Yust add event handler for each sub menu

      ToolStripMenuItem subItem = new ToolStripMenuItem(CenterTables[i]);
      subItem.Click += new System.EventHandler(subItem_Click);
      firstItem.DropDownItems.Add(subItem);

      Also there is no Select Event, but Click. 3rd: You can get item in Event Handelr This code is in event handler and gets ToolStripMenuItem from Object that is passet into event handler. So every SubItem with a can use same event handler and can be distinguished betwen them

      ToolStripMenuItem mnu = sender as ToolStripMenuItem;

      A 1 Reply Last reply
      0
      • S Saksida Bojan

        1st.: Don't add event on top level item 2nd: Yust add event handler for each sub menu

        ToolStripMenuItem subItem = new ToolStripMenuItem(CenterTables[i]);
        subItem.Click += new System.EventHandler(subItem_Click);
        firstItem.DropDownItems.Add(subItem);

        Also there is no Select Event, but Click. 3rd: You can get item in Event Handelr This code is in event handler and gets ToolStripMenuItem from Object that is passet into event handler. So every SubItem with a can use same event handler and can be distinguished betwen them

        ToolStripMenuItem mnu = sender as ToolStripMenuItem;

        A Offline
        A Offline
        AhmedMasum
        wrote on last edited by
        #3

        It's great!!!! Thanks a lotz

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups