Hello! i’have a MenBar with lots of MenuItem controls, and one xml file. In the xml file i have many control’s names ans it level of permision (enabled, etc…). With one foreach sentence i get all the menuitems, and i want that, with its name, search it in the xml file and get if i have to enable it or not… But the menuitem controls haven´t the name property!! how can i get it?? thanks for all
Imported from legacy forums. Posted by Evius (had 2536 views)
From what I have seen, you are correct in that you cannot retrieve the name of a menu item object via any of its member properties.
However, based on what you would like to do, there is a way to get around that. Whenever you assign a name to a menu item object, you should also assign that same name to the Tag property of that object too. The Tag property can be used to hold any object type you would like to hold, so it will be suitable for your needs.
This way whenever you run the For loop, you can look at each menu item’s Tag property, get the name from there (by casting the object type to a string), and then do your comparison.
Hope this helps!
Imported from legacy forums. Posted by paulplatter (had 292 views)
By the way, you can also use the Key member property of the menu item to accomplish the same thing. This way you won’t even have to cast it’s value back to a string, since the Key is already a string type. You still will need assign the Key property the same value as the Name property though.
Imported from legacy forums. Posted by paulplatter (had 3548 views)