Solved

Dynamic Menu in Windows C# Application

Posted on 2006-07-20
1
493 Views
Last Modified: 2008-01-09
In my c# windows application, I have created 10 drop down menu's, mnuFile0, mnuFile1, ...., mnuFile9.  I've read in a field from a db and wish to update the .Text items of the drop down menu's to the contents of the db field.  In action script, this would be the way (using eval command):

for (i=0; i<9; i++) {
    MenuItem mnu = Eval("mnuFile" + i);
    mnu.Text = DBRecordField[i];
    mnu.Visible = True;
}

After spending some time researching FindControl(ID) only to realize this was for web pages, is there a C# windows application equivelant to Eval?  Somehow I get the feeling there isn't, is there another way?

Many thanks.
0
Comment
Question by:daviesgroup
1 Comment
 
LVL 12

Accepted Solution

by:
sumix earned 250 total points
ID: 17147146
your 10 menuitems should be part of a MenuItems collection of a Mainmenu or other menuitem control, can't you just loop this collection?

for (int i=0;i<menuItem1.MenuItems.Count;i++)
// or for (int i=0;i<mainMenu1.MenuItems.Count;i++)
{
   menuItem1.MenuItems[i].Text = DBRecordField[i];
 }
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question