Solved

Dynamic Menu in Windows C# Application

Posted on 2006-07-20
1
509 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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