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?
Thanks in advance
Rakesh 9 3669
Rakesh,
The designer accomplishes the name property by actually extending your
class and then hosting that in the property grid. The Name property is then
expose off that derived class. The Name property is really the name of the
variable, which you should know already. If you don't, then you will need
to place the identifier of some sort on the MenuItem (by extending the
MenuItem class and attaching your information).
What are you trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Rakesh" <an*******@disc ussions.microso ft.com> wrote in message
news:0b******** *************** *****@phx.gbl.. . 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?
Thanks in advance Rakesh
I have the same problem
I am trying to build an MDI template other developers can customize later.
I want to include code on the mainform that will enable or disable menuitems added later given only their names. the function will be called from a child form. These menuitems do not exist at design time for the template
I have code that works using the text property but this does not allow for common names. E.g. File/new and Window/new both get disabled or enabled at the same time.
It sounds like I have a similar problem
I am working on an MDI template and I want to place code on the mainform to enable or disable menuitems.
The first problem is I must cope with menu items that do not exist while I am designing the template, they can be added later by another developer. I do not want to make the menu items public and open the existing items to tampering
The trigger to disable an item will originate from a child form which will not know about the menuitem objects and must pass a string to identify an item
I have code that works using the Text property but it won't allow for common item names. e.g. it thinks File/new and Window/new are the same thing
the second problem is processing the menu selections. If you want to process the menu click on the child form and cannot pass it an object, how do you identify the menu item? Remembering that the item in question was added to a derived form not the original template
----- Nicholas Paldino [.NET/C# MVP] wrote: ----
Rakesh
The designer accomplishes the name property by actually extending you
class and then hosting that in the property grid. The Name property is the
expose off that derived class. The Name property is really the name of th
variable, which you should know already. If you don't, then you will nee
to place the identifier of some sort on the MenuItem (by extending th
MenuItem class and attaching your information)
What are you trying to do
--
- Nicholas Paldino [.NET/C# MVP
- mv*@spam.guard. caspershouse.co
"Rakesh" <an*******@disc ussions.microso ft.com> wrote in messag
news:0b******** *************** *****@phx.gbl.. 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-tim right Thanks in advanc Rakes to***********@g mx.de (Torsten Kraus) wrote in message news:<eb******* *************** ****@posting.go ogle.com>... hi there,
i've had the same problem. Unfortunally MenuItem and ToolBarButton have no Name property. But the name Property is only the Name of the Variable/Field. So you can figure out the Name of a ToolBarButton or MenuItem using Reflection.
The following Sample retreive the Name of a given ToolBarButton:
public static string GetToolBarButto nName(System.Wi ndows.Forms.For m frmParent, System.Windows. Forms.ToolBarBu tton tbButton) { FieldInfo[] fields = frmParent.GetTy pe().GetFields( System.Reflecti on.BindingFlags .NonPublic|Syst em.Reflection.B indingFlags.Pub lic|System.Refl ection.BindingF lags.Static|Sys tem.Reflection. BindingFlags.In stance); foreach(FieldIn fo field in fields) { if (field.GetValue (frmParent) == tbButton) return field.Name; } return ""; }
ciao Torsten
Hi
The code above works fine for Menu object, but not MenuItem object.
Any ideas?
Thx,
Carel
I've had the same problem as Rakesh
I've got a Menu in my application that will be changing from time to time as I revise the application throughout the remainder of it's Alpha stage, and possibly during it's Beta stage
I've got upwards of 50 MenuItems under one particular Menu selection. I'm using a try-catch-end try to catch several exceptions that are sometimes thrown. Instead of using 50+ subProcedure declarations, I did one declaration that handles all of the menuitems that I need. However, when I went to do a select case decision structure, I found out the hard way that .name is not a property, but a protected or private field that was never made accesible via a string readonly property. I think the .NET developers need to fix this, as MANY controls have a string readonly property for access at run time
Dolphin Incarnate to***********@g mx.de (Torsten Kraus) wrote in message news:<eb******* *************** ****@posting.go ogle.com>... hi there,
i've had the same problem. Unfortunally MenuItem and ToolBarButton have no Name property. But the name Property is only the Name of the Variable/Field. So you can figure out the Name of a ToolBarButton or MenuItem using Reflection.
The following Sample retreive the Name of a given ToolBarButton:
public static string GetToolBarButto nName(System.Wi ndows.Forms.For m frmParent, System.Windows. Forms.ToolBarBu tton tbButton) { FieldInfo[] fields = frmParent.GetTy pe().GetFields( System.Reflecti on.BindingFlags .NonPublic|Syst em.Reflection.B indingFlags.Pub lic|System.Refl ection.BindingF lags.Static|Sys tem.Reflection. BindingFlags.In stance); foreach(FieldIn fo field in fields) { if (field.GetValue (frmParent) == tbButton) return field.Name; } return ""; }
ciao Torsten
Hi
The code above works fine for Menu object, but not MenuItem object.
Any ideas?
Thx,
Carel
I've had the same problem as Rakesh
I've got a Menu in my application that will be changing from time to time as I revise the application throughout the remainder of it's Alpha stage, and possibly during it's Beta stage
I've got upwards of 50 MenuItems under one particular Menu selection. I'm using a try-catch-end try to catch several exceptions that are sometimes thrown. Instead of using 50+ subProcedure declarations, I did one declaration that handles all of the menuitems that I need. However, when I went to do a select case decision structure, I found out the hard way that .name is not a property, but a protected or private field that was never made accesible via a string readonly property. I think the .NET developers need to fix this, as MANY controls have a string readonly property for access at run time
Dolphin Incarnate to***********@g mx.de (Torsten Kraus) wrote in message news:<eb******* *************** ****@posting.go ogle.com>... hi there,
i've had the same problem. Unfortunally MenuItem and ToolBarButton have no Name property. But the name Property is only the Name of the Variable/Field. So you can figure out the Name of a ToolBarButton or MenuItem using Reflection.
The following Sample retreive the Name of a given ToolBarButton:
public static string GetToolBarButto nName(System.Wi ndows.Forms.For m frmParent, System.Windows. Forms.ToolBarBu tton tbButton) { FieldInfo[] fields = frmParent.GetTy pe().GetFields( System.Reflecti on.BindingFlags .NonPublic|Syst em.Reflection.B indingFlags.Pub lic|System.Refl ection.BindingF lags.Static|Sys tem.Reflection. BindingFlags.In stance); foreach(FieldIn fo field in fields) { if (field.GetValue (frmParent) == tbButton) return field.Name; } return ""; }
ciao Torsten
Hi
The code above works fine for Menu object, but not MenuItem object.
Any ideas?
Thx,
Carel
I've had the same problem as Rakesh
I've got a Menu in my application that will be changing from time to time as I revise the application throughout the remainder of it's Alpha stage, and possibly during it's Beta stage
I've got upwards of 50 MenuItems under one particular Menu selection. I'm using a try-catch-end try to catch several exceptions that are sometimes thrown. Instead of using 50+ subProcedure declarations, I did one declaration that handles all of the menuitems that I need. However, when I went to do a select case decision structure, I found out the hard way that .name is not a property, but a protected or private field that was never made accesible via a string readonly property. I think the .NET developers need to fix this, as MANY controls have a string readonly property for access at run time
Dolphin Incarnate This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tony |
last post by:
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!
|
by: Claus Holm |
last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather
than making the menuitems public, I'd go for a public method in the parent
form to do the change, but when I call the method from the mdichild, I get
this error:
C:\MyProjects\Visual Studio Projects\Tournament\Forms\frmLogin.cs(69): The
name 'test' does not exist in the class or namespace 'Tournament.frmLogin'
frmLogin is the mdichild.
|
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...
|
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...
|
by: Agnes |
last post by:
dim c as controls
for each c in me.controls
messagebox.show(c.name)
next c
I found that the menu time didn't show up ?? It didn't belongs to the
control in the form ???
I need to Me.mnuXXX.Enabled = false during run-time
Anyone know how can do that ??
| |
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
|
by: Michael |
last post by:
Hi Everyone,
I seem to be having a problem accessing a menuitem on the MDIParent from a
child form. From a login (frmSecurity -child form) screen, I need to hide a
menuitem based on the users role. The problem is that I can't seem to get
access to the menuitem. I can't get it with code like:
MDIParent.mnuAdministrator.Visible = true
MDIParent is the name of the form I gave. This is also the Startup form (in
the project settings) if this...
|
by: Jason Huang |
last post by:
Hi,
Would someone tell me how to get a MenuItem's Name in a C# Windows Form?
Thanks for help.
Jason
|
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,...
|
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...
|
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,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |