Solved

Finding MenuItem at runtime in C#

Posted on 2008-10-11
3
1,347 Views
Last Modified: 2013-11-23
Hi
I am trying to find items of memuitem at runtime. I am using this code for this
foreach(Control ctr in this.Controls)
{
     if (((MenuItem)ctr).Name == "AAA")
      {
         MessageBox.Show("ok");
       }
}
but it says me cannot convert Control to MenuItem

I need something like  TMenuItem(Menu.FindComponent('AAA')) in delphi
thanks...
 
0
Comment
Question by:Lucky3664
  • 2
3 Comments
 
LVL 7

Expert Comment

by:lucky_james
ID: 22693098
0
 
LVL 7

Accepted Solution

by:
lucky_james earned 50 total points
ID: 22693140
also, in order to find the name of menu item at runtime, there is already one discussion:
http://www.experts-exchange.com/Programming/Misc/Q_21462408.html


Hope this helps.

James
0
 
LVL 11

Expert Comment

by:Mihai Stancescu
ID: 22738152
Try this:
foreach(Control ctr in this.Controls)
{
     if (ctr is MenuItem)
     {
           if ((ctr as MenuItem).Name == "AAA")
           {
                 MessageBox.Show("ok");
            }
     }
}
Hope this helps!

Regards,
Mishu
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

708 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

11 Experts available now in Live!

Get 1:1 Help Now