Solved

Dynamic Menu in Windows C# Application

Posted on 2006-07-20
1
501 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to repeat the data 4 30
Problem to Office 1 45
c#, case, if 4 22
.Net remove carriage returns, line feeds and tabbs 5 16
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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