J
Jeff Mason
I have an application where I need to set certain menu items invisible based on a
user privilege.
We did a sinmlar thing in VB6 and used the menu item's tag property to assign an
identifier to each menu entry, then used that identifier as an index into a
collection populated at user login in order to determine the item's visibility.
Now, for some reason there's no tag property for .NET MenuItems, so I'm looking for
some way to accomplish what I was able to do in VB6. If I could get access to the
menu name assigned at design time that could work, but I can't see how to do that.
It's not available at run time via the menu item's type.
The sample code in help has hideous If/Then/ElseIf structures like:
If menuitem is mnuFile Then
...
elseif menuitem is mnuEdit then
...
elseif...
But there has to be a better way to uniquely identify a menuitem at run time.
I suppose I could derive a class from MenuItem and define my own tag or other
identifier property, but then I wouldn't be able to use that class in the menu
designer.
Is it possible to discover the specific instance of the menuitem via reflection
somehow?
user privilege.
We did a sinmlar thing in VB6 and used the menu item's tag property to assign an
identifier to each menu entry, then used that identifier as an index into a
collection populated at user login in order to determine the item's visibility.
Now, for some reason there's no tag property for .NET MenuItems, so I'm looking for
some way to accomplish what I was able to do in VB6. If I could get access to the
menu name assigned at design time that could work, but I can't see how to do that.
It's not available at run time via the menu item's type.
The sample code in help has hideous If/Then/ElseIf structures like:
If menuitem is mnuFile Then
...
elseif menuitem is mnuEdit then
...
elseif...
But there has to be a better way to uniquely identify a menuitem at run time.
I suppose I could derive a class from MenuItem and define my own tag or other
identifier property, but then I wouldn't be able to use that class in the menu
designer.
Is it possible to discover the specific instance of the menuitem via reflection
somehow?