Click here to Skip to main content
Click here to Skip to main content

Improvement of the .NET Menu Style class

By , 14 Jan 2003
 

Sample Image - nicemenu.png

Introduction

With this new ".NET Menu Style" class you can get a great menu with only few lines of code. You don't have to write a line of code for each menu item because your menu now will be AUTOMATICALLY updated! This is very useful, 'cause now you can still build and update your menu with the VS.NET tool, but at runtime you'll have always a new fresh .NET style menu. Another improvement is about the menu images, now you can use a simple imagelist to store your icon, and with a line of code and a simple trick (to add the index of the image near the text of the menu item), you'll get your image near your menu item.

I've updated this class, now you can use icons with context menu and search for a MenuItem at runtime with an easy function. Now you can also download a nice RTF file editor that use the .NET style menu. This RTF file editor is still under development, however it's already a good example of C# programming.

Using the code

You have to add:

using Utility.NiceMenu;

and after the "InitializeComponent()" code:

NiceMenu myNiceMenu = new NiceMenu();
myNiceMenu.UpdateMenu(this.nameofyourmainmenu, 
    new NiceMenuClickEvent(nameofyourclickfunction));

If you want to add some incons in your menu you have to:

  • add an imagelist control in your form
  • add your icons in your imagelist control
  • add in your menu items the index of the icon in the first two characters. For example:
    • 00New
    • 01Open
    • 02Close
  • After the NiceMenu myNiceMenu = new NiceMenu(); code you have to add this simple line of code:
myNiceMenu.imgMenu = nameofyourimagelist; 

Points of Interest

There are a lot of comments with the code, so... enjoy!

History

This is an improvement by Francesco Natali over an improvement by Sajith M of the "Visual Studio .NET Menu Style" by Carlos H. Perez

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Francesco Natali
Web Developer
Italy Italy
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralContext Menu and CloneMenu Methodmembermarianod2@hotmail.com22 Aug '03 - 9:12 
When I use the CloneMenu Method, the menu disapear
, why? It's a bug? Anyway, very good improvement!
 
Dim mnuMain As MainMenu = Me.ParentForm.Menu.CloneMenu
 
mnuCtxtrvOrders.MenuItems.Add(mnuMain.MenuItems.Item(0))
thanks
 


 
Mariano
GeneralOffice 2003 Menu Stylemember8MX10 Apr '03 - 10:48 
http://www.devcomponents.com have just released their Office 2003 Menu Style.
As we here look for free stuff, how about updating this great menu with Office 2003 style ?
Rose | [Rose] Blush | :O

GeneralRe: Office 2003 Menu StylememberRay Cassick10 Apr '03 - 11:48 

http://www.devcomponents.com[^]
 

Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.


GeneralBad CodememberTemplMetaProg28 Mar '03 - 1:38 
Sizes are incorrect (Menu items are HUGE!). Top-level bar is incorrect. Icons are kinda dodgy. Can't someone get it right, please?
 
nous sommes les maitres
nous sommes les esclaves
nous sommes partout
nous sommes nul part
nous maitrisons les lettres noires Smile | :)

GeneralRe: Bad Codemember.S.Rod.28 Mar '03 - 1:58 

Feel free to contribute instead of whining.

GeneralEqual Menuitem Namemembermveiga23 Jan '03 - 16:37 
If I have two menuitem equals in differents menus, e.g., File->New and Customer->New, the click event only founds File->New. How can I know exactly which menuitem was clicked ?
 
Thanks
GeneralRe: Equal Menuitem Namememberlonelywind19826 Apr '06 - 17:33 
You can try &New for File -> New, N&ew for File -> New and Customer. Not best solution but it work.
GeneralVB .NETmemberjadeboy17 Jan '03 - 1:03 
Got a VB .NET Version?
Generalsome proplemmemberchinadeer11 Jan '03 - 2:32 
when use ContextMenu ,it have not icons....why....
 
mainmenu is ok....Cry | :((
GeneralRe: some proplemmemberFrancesco Natali15 Jan '03 - 5:46 
chinadeer wrote:
when use ContextMenu ,it have not icons....why....
 
Try to download the new version!
Bye.
Smile | :)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 15 Jan 2003
Article Copyright 2002 by Francesco Natali
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid