I'm building a menu dynamically at runtime based on an XML document. I have something like...
MenuItem Text="Menu 1" Tag="Form1" MenuItem Text="Menu 1.1" Tag="Form2" MenuItem Text="Menu 1.1.1" Tag="Form3" MenuItem Text="Menu 1.1.2" Tag="Form4" MenuItem Text="Menu 1.1.3" Tag="Form5" MenuItem Text="Menu 1.2" Tag="Form6" MenuItem Text="Menu 1.3" Tag="Form7" MenuItem Text="Menu 1.3.1" Tag="Form8" MenuItem Text="Menu 1.3.2" Tag="Form9" I wrote some basic logic to load these into a menu strip as individual menu strip items. This work fine! However, now I want to create a function to process the items when they are clicked on. Within the menu items there are tag values that identify the program name. So if they click on "Menu 1.3.1", I need to execute Form9. I can get Form9 to execute based on a subroutine I created that passes in the form name as a string. However, what I cannot get is an easy way to have ALL the menu clicks to pass through a single function where I can pull out the tag value and call my form execution subroutine. Does anyone know how to create a single event for ALL of the menu clicks on a menu strip? The problem seems to be that .Net seems EACH menu strip item as an individual object with events. However, I just want ALL menu clicks to process through a single event. Any idea what the event should be? If I cannot do this, then I will need to wire up an event for EACH of the menu items as I add them to the menu. I'm not sure how to do that either. How do you add events to items that you create dynamically? I have done that in the past but I do not recall what I did. What I was hoping is that I could create ONE menu item event and hook it up programmatically to EACH menu item that I add to the menu item strip at run time. Any thoughts, suggestions, ideas would be very much appreciated. Best regards, Greg =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com