473,854 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Identifying menus

I am an experienced VB 3-6 developer moving to .NET.

In VB 6 i could go through the form controls collection ,
find all the menu items and using security information set-
up I could enable/dissable menu items based on their name.

DOT NOT has appeared to complicate this no end.

1. menuitem & toolbatbutton controls do not expose a name.
2. context menus are Container.Compo nents

Real pain the the ..rs.

Is there a way of doing it in dot net.
Jul 21 '05 #1
1 1304
You could add your own properties to the controls interface through
inheritance:

public class MyMenuItem : System.Windows. Forms.MenuItem
{
string id;

public MyMenuItem(stri ng Text, EventHandler OnClick, string ID) :
base(Text, OnClick)
{
id = ID;
}
public string ID
{
get { return id; }
set { id = value; }
}
}

Or, test with equals against the instance of the object:

MyMenuItem mymenu;

public Form1()
{
InitializeCompo nent();
MainMenu myMenu = new MainMenu();
MenuItem File = myMenu.MenuItem s.Add("&File");
mymenu = new MyMenuItem("My Menu Item", new EventHandler(th is.clicked),
"MYMENUITEM ");
File.MenuItems. Add(mymenu);
}
private void clicked(object sender, EventArgs e)
{
if (sender == mymenu)
MessageBox.Show ("YeeHaw");
}

HTH,
Eric Cadwell
http://www.origincontrols.com
Jul 21 '05 #2

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

Similar topics

21
2245
by: dkcpub | last post by:
I'm very new to Python, but I couldn't find anything in the docs or faq about this. And I fished around in the IDLE menus but didn't see anything. Is there a tool that can determine all the exceptions that can be raised in a Python function, or in any of the functions it calls, etc.? /Dan
7
2751
by: Marci | last post by:
I found this script for cascading menus, however, I cannot reach the author to solve the bug I am having when I add a second menu to it. My problem is this: If I click on the first link, the menu displays well. If I then click on the second link, the first menu from the first link still displays. How do I get make the first menu disappear when I click on the second and vice versa? Please help...thanks.
1
11333
by: cefrancke | last post by:
I have set the Startup properties to the following... All menus, toolbars, etc are turned off plus these are unchecked Allow Full Menus Allow Built-in Toolbars Allow Default Shortcut Menus Allow Toolbar/Menu Changes Use Access Special Keys
3
11536
by: cefrancke | last post by:
The only reason I ask is that no one has made this subject clear or given a definitive answer. What I would like to do is, after turning off all the menus/tbars/etc using the startup options. Upon restarting Access, when an admin is detected (I use a GetSystemUser() function) I want to restore everything so that Access behaves like normal, ie. all menus/tbars/etc show up (only where they are supposed to show up).
0
3567
by: cefrancke | last post by:
I recently discovered, that if you set the startup options for "security", you will have alot of work do to get Access back to "normal". If you disable the built-in menus/toolbars you'll have to reconstruct the one you want as a custom menu/shortcut(popup)/toolbar. All this was a long journey in order to allow the user to sort/copy on a datasheet view of a subform, with all the menus disabled in the startup options.
4
1709
by: Karl Irvin | last post by:
I distribute an A 2000 app as a mde. On a few customers, my custom menus are overwritten. The top menu is generally there but the choices on the menus are gone or replaced by something else. I can't figure this one out. Any ideas on what may be causing this? It happens on machines with A 2000 and A 2003, Win Home and Win XP. I've yet to see a pattern but it happens on about 3 or 4% of the users machines.
3
1786
by: Steven Smith | last post by:
the way I'm undersatnding the MSDN documentation when creating parent and child forms the main menu for the child form should not be displayed on the child form itself but instead be incorporated into the parent forms main menu, however I just cannot make this work, with the parents main menu being displayed at all times, I know this is rather vague but hopefully someone may have encountered a similar problem at sometime and may be able...
1
210
by: Adelio Stevanato | last post by:
I am an experienced VB 3-6 developer moving to .NET. In VB 6 i could go through the form controls collection , find all the menu items and using security information set- up I could enable/dissable menu items based on their name. DOT NOT has appeared to complicate this no end. 1. menuitem & toolbatbutton controls do not expose a name. 2. context menus are Container.Components
0
2928
by: ARC | last post by:
Hello all, For right-click (shortcut) menus in access 2007, I've been using a round-about method of opening access 97 on an old computer, modifying my own custom shortcut menus, then importing the menus only into my access 2007 project. This is proving cumbersome (especially since my old pc with access 97 likes to blue screen when running acc 97), and I was wondering if there's an easier way?
0
9752
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,...
0
11031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10685
jinu1996
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...
0
10371
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
9518
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
7918
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
7082
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();...
1
4563
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
2
4162
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.