Getting a MenuItem's Name

JDYoder

Centurion
Joined
Nov 18, 2003
Messages
144
With a MainMenu control on my form, I can loop thru the top level menu easy enough. Assuming my control is named mnuMain, I just use the following...

For i = 0 To (mnuMain.MenuItems.Count) - 1
' Do stuff with mnuMain.MenuItems.Item(i)
Next i

However, I can't figure out how to reference a menuitem's name since mnuMain.MenuItems.Item(i) has no Name property that appears via intellisense. But I know it has one since I assigned a name to each menuitem while in design mode. I can easily reference the Text property...

mnuMain.MenuItems.Item(i).Text

... and some other properties, but there's no .Name -- what am I missing?
 
Realize the difference between a component and a control. A control has a name property which corresponds to the variable name that you give it at design time... a component does not have a name property... the name that you assign it in the properties window is the name of the variable as it is declared in the Windows Forms Designer code. :)
 
Back
Top