Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is is possible to retrieve the menu items names?

 

I can make it list the Menu items .Text:

 

foreach (System.Windows.Forms.MenuItem cCtrl in mainMenu.mainMenu1.MenuItems)
{
	foreach (System.Windows.Forms.MenuItem cCtrlSub in cCtrl.MenuItems)
		{
			MessageBox.Show(cCtrlSub.Text.ToString());
		}
}

 

Unfortunatey the System.Windows.Forms.MenuItem does not have the ".Name" propperty...

 

Is there any other way to make a loop where i can get a list of all menuItems names?

  • Leaders
Posted

Why would you need the Name of the menus? Menuitems do not carry names around like controls do, and they're pretty much like an integer or a string... they don't carry a name.

If you need to reference a control, use the reference to the control. Don't try to do something overly complicated with the name of the menu. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted
Why would you need the Name of the menus? Menuitems do not carry names around like controls do, and they're pretty much like an integer or a string... they don't carry a name.

If you need to reference a control, use the reference to the control. Don't try to do something overly complicated with the name of the menu. :)

 

Imagine a button control...

The point to get the control.name is that u can modify its control.text and perserving the control name, so if I point to a control.name it will always be "ok" no matter how many changes its .text property suffers... The hole thing was to put into the database all menuitems (.name) in fields true / false, so that I could choose wich menuitems would be enabled / disabled, Visible (true, false). Yet, the program would automaticaly add a colunm into the database if a new menu would be add to the program, by using only the text reference, everytime I rename the menuItem.text, a column will be add into the database, whitch I dont wan't!. (there is not even the tag property which could do the same job .name would do)...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...