Solved

Finding MenuItem at runtime in C#

Posted on 2008-10-11
3
1,349 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

943 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

10 Experts available now in Live!

Get 1:1 Help Now