Solved

Finding MenuItem at runtime in C#

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

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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Why use this lambda? 12 95
itextsharp with c# 3 33
parsing question on dynamic concatenation 3 39
Why am I losing my session variable value 11 39
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

734 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