Home Forums WinForms controls Other WinForms controls How get the name Reply To: How get the name

User (Old forums)
Member
Post count: 23064

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)