Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Customer menu items
Message
Information générale
Forum:
ASP.NET
Catégorie:
Menus
Divers
Thread ID:
01085141
Message ID:
01085227
Vues:
38
Hi Peter,

>Hello All, anybody know if there is a way to tell Visual Studio 2003 to add a user defined menu item ?

To get a feel for this you can look at the windows form designer code region for hints on how to do this (although the code is spaced out through the region).

Basically you instantiate a System.Windows.Forms.MenuItem, and then add it to the MenuItems collection of the menu item that will be its parent.

For example, lets say that I have a File pad in my menu called FilePad (it will be of type System.Windows.Forms.MenuItem).

The code below instantiates two menu items (New and Open) and adds them to the MenuItems collection of FilePad. Next it fills in the text and shortcut for the New menuitem, and registers the method that will be called when the New is chosen frmo the menubar.
this.FileNewBar = new System.Windows.Forms.MenuItem();
this.FileOpenBar = new System.Windows.Forms.MenuItem();
this.FilePad.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
					this.FileNewBar,
			                this.FileOpenBar }
this.FileNewBar.Index = 0;
this.FileNewBar.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
this.FileNewBar.Text = "New";
this.FileNewBar.Click += new System.EventHandler(this.FileNewBar_Click);
...
In your application you would have to change the last line above to point the click event to the event handler method that will handle what happens when the menuitem is chosen.
Rick Hodder
MCP Visual Foxpro
C#, VB.NET Developer
Independent Consultant
www.RickHodder.com
MyBlog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform