Doing this kind of thing can be helpful. Basically when you create the menuitem you give it a unique identifier of your chosen type (here an integer based on a database primary key but can be a string or a form ref or an elephant). Note my scoping is sloppy.
Friend Class DataMenuItem Inherits MenuItem 'just a menu item that retains a PK reference from creation Public Sub New(ByVal intItemID As Integer) DatabaseID = intItemID End Sub Friend DatabaseID As Integer End Class Whack a new menuitem on like: MyItem = New DataMenuItem(MyInteger) MyItem .Text = "Blah" MyMenu.MenuItems.Add(MyItem) Then you can CType the sender to a DataMenuItem in your click event no worries and get your desired ID out. Hope I have grasped your issue OK! Cheers, Iain -----Original Message----- From: JC Oberholzer [mailto:[EMAIL PROTECTED]] Sent: 13 August 2002 13:41 To: [EMAIL PROTECTED] Subject: [ADVANCED-DOTNET] Name of MenuItem through Reflection I need to extract the name of a menuitem at runtime using reflection, but it does not have a name property or any custom property which seems appropriate! The situation is: I set up the security for the controls on the form dynamically from a db in the backend using the names of the controls on the form. Works well for everything, except the menu's, as these are not in the controls collection. When a menuitem recieves the "Click" event, I can identify the menuItem by using the event parameter Sender. A MenuItem does not have a Name property however, so I'm back to square one! I tried to extract the name of the local variable that defines the instance (private withevents mymenu as ....), but am struggling to get this. Can anyone help me to extract anything unique per menu item (which is human readable as well) or maybe help me cycle through the local variables on the form (to compare it to the Sender object in the click event) Thanks JC Oberholzer You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. Disclaimer This message may contain information which is legally privileged and/or confidential. If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification not withstanding, any comments or opinions expressed are those of the originator, not of Taylor Made Computer Solutions, unless otherwise explicitly stated. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.