Finding MenuItem at runtime in C#

Posted on 2008-10-11
Last Modified: 2013-11-23
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")
but it says me cannot convert Control to MenuItem

I need something like  TMenuItem(Menu.FindComponent('AAA')) in delphi
Question by:Lucky3664
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

Accepted Solution

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:

Hope this helps.

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")
Hope this helps!


Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
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…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

717 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