Apprentyly just create a new obj of the correct type and setting them equal... will give me access to the properties of the sender object. Never tried that before.
Is that the recommended way to do this sort of thing? Here's an example that seems to work. Greg Private Sub MenuStrip_ItemClicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim obj As ToolStripMenuItem obj = sender Dim str As String = "" & obj.Tag MsgBox("Tag value: " & str) End Sub -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Tracy Ding Sent: Thursday, July 12, 2007 12:37 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Runtime Created MenuStripItems - Click Event Handler Use Addhandler method to add event handler programmtically. Best Regards, Tracy Ding -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Jon Rothlander Sent: Thursday, July 12, 2007 10:11 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: [ADVANCED-DOTNET] Runtime Created MenuStripItems - Click Event Handler 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(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com