Solved

Dynamic Menu in Windows C# Application

Posted on 2006-07-20
1
485 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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now