Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Finding MenuItem at runtime in C#

Posted on 2008-10-11
3
Medium Priority
?
1,359 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
[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
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
lucky_james earned 100 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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.
Suggested Courses

604 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