?
Solved

Finding MenuItem at runtime in C#

Posted on 2008-10-11
3
Medium Priority
?
1,358 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

764 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