How to get item clicked event for ContextMenus Dropdown item clicked
-
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...**
-
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...**
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;
-
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;
It's great!!!! Thanks a lotz