473,756 Members | 8,110 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the name of menuitem at runtime?

like this,
foreach (MenuItem item in this.mainMenu1. MenuItems)
{
//some code
//I want to get the menuitem's name here!

}
No name property found. please help!
Nov 16 '05 #1
4 4988
item.Text?

--
Adam Clauss
ca*****@tamu.ed u
"Tony" <co******@21cn. com> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
like this,
foreach (MenuItem item in this.mainMenu1. MenuItems)
{
//some code
//I want to get the menuitem's name here!

}
No name property found. please help!

Nov 16 '05 #2
Hi,

What you mean with the name of the menuitem?

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tony" <co******@21cn. com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
like this,
foreach (MenuItem item in this.mainMenu1. MenuItems)
{
//some code
//I want to get the menuitem's name here!

}
No name property found. please help!

Nov 16 '05 #3
Like other controls Name property is not available for use.

Couple of recomendations

1. While constructing the menu, create a hashtable.

2. Derive a class from menuitem and add your own properties to store menu
name.

Shak.
"Tony" <co******@21cn. com> wrote in message
news:#R******** ******@TK2MSFTN GP09.phx.gbl...
like this,
foreach (MenuItem item in this.mainMenu1. MenuItems)
{
//some code
//I want to get the menuitem's name here!

}
No name property found. please help!

Nov 16 '05 #4
On Thu, 24 Jun 2004 13:25:26 -0500, "Shakir Hussain"
<sh**@fakedomai n.com> wrote:
Like other controls Name property is not available for use.
MenuItem is just a component, not a control -- that's why it doesn't
have a "real" Name property. The Name property of real controls is
certainly available for use from outside the designer.
2. Derive a class from menuitem and add your own properties to store menu
name.


Yes, that's perhaps the best approach.
--
http://www.kynosarges.de
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3674
by: Rakesh | last post by:
Hi, I am able to obtain a MenuItem object's Name property @ design-time, but am not able to get the same @ run- time...why? And since MenuItem doesn't inherit from Control class, it's not even supposed to be available @ design-time right?
2
1609
by: M Shafaat | last post by:
Hi, I want to develop an application with menus. I want to make only one event handler method which handles a whole group of menu items by firstly identifying which MenuItem sends the click event and then performing the appropriate action. But I don't find any way to retrieve any info telling me which specific MenuItem sends a click event at the moment. The sender and e parameters seem to carry some very general information, not from a...
3
1344
by: Sachin D. | last post by:
In VB.net menus, there is a name property, but it isnt available in runtime..strange!!! does someone has a idea how i can do something similar? reason i want it is...in my app the UI text comes from a language table in database. For form and control text i retrieve it using the formname+control name. But doing the same thing for menu is not possible. One idea is to store the name of the menu item e.g. mnuFile in the text itself
3
1242
by: Edwin Bach | last post by:
how can you get the name of a menuitem programatically and return is as a string, for example if Friend WithEvents mnuExit As System.Windows.Forms.MenuItem is defined how can you go get the mnuExit TIA Ed
15
2473
by: Jeff Mason | last post by:
I have an application where I need to set certain menu items invisible based on a user privilege. We did a sinmlar thing in VB6 and used the menu item's tag property to assign an identifier to each menu entry, then used that identifier as an index into a collection populated at user login in order to determine the item's visibility. Now, for some reason there's no tag property for .NET MenuItems, so I'm looking for some way to...
4
1831
by: Jeff Mason | last post by:
I have an application where I need to set certain menu items invisible based on a user privilege. We did a sinmlar thing in VB6 and used the menu item's tag property to assign an identifier to each menu entry, then used that identifier as an index into a collection populated at user login in order to determine the item's visibility. Now, for some reason there's no tag property for .NET MenuItems, so I'm looking for some way to...
6
4461
by: Rob Willaar | last post by:
Hi all, Can i get the Name of a menu object in the Click event handler? tnx for any help
2
1247
by: Agnes | last post by:
I know how to get the Menuitem's TEXT . BUT I need to get the names , Does anyone know how to do ?? Thanks I try That " For Each FileMenuItem As MenuItem In Me.Menu.menuitem" before
2
2166
by: polocar | last post by:
Hi, I'm writing a program using Visual C# 2005 Professional Edition, and I was trying to assign multiple MainMenu objects (one by one, of course) to the same Form (let's suppose 2 MainMenu objects). It is possible (and it's my case) that these 2 MainMenu objects use some different MenuItem objects and some identical MenuItem objects. For example, let's assume that: mainMenu1 contains miFile, miEdit, miHelp mainMenu2 contains miFile,...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.