EFileTahi-A Posted October 28, 2004 Posted October 28, 2004 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? Quote
Leaders Iceplug Posted October 28, 2004 Leaders Posted October 28, 2004 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. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
EFileTahi-A Posted October 28, 2004 Author Posted October 28, 2004 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)... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.