Click here to Skip to main content
Licence 
First Posted 2 Dec 2002
Views 178,754
Bookmarked 50 times

Improvement of the .NET Menu Style class

By | 14 Jan 2003 | Article
This is an improvement by Francesco Natali over an improvement by Sajith M of the "Visual Studio .NET Menu Style" by Carlos H. Perez

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



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. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralGreat tool. Beware if you re using multiple context menues Pinmemberanton_fernando10:29 25 Jun '07  
GeneralConverting to Visual Studio 2005 ToolStripMenuItem PinmemberVeeran Kutty7:38 31 Jan '06  
GeneralConvenient click handler for menu PinmemberCoreyRIT7:58 6 Jan '06  
GeneralRe: Convenient click handler for menu Pinmemberanton_fernando9:55 23 May '06  
GeneralAdding a Windows Form to a menu PinmemberJim Barber19:18 27 Aug '05  
AnswerRe: Adding a Windows Form to a menu Pinmemberillium18:45 31 Jul '06  
Generalsubmenu arrow PinmemberSoTTo4:45 27 Jun '05  
QuestionMC++ ? PinmemberCppBeginner0:55 9 Oct '04  
QuestionEnabled works?? Pinmembermpwt0:58 17 Sep '04  
Generalvery nice tool Pinmembersherb2:19 13 Sep '04  
GeneralRe: very nice tool PinsussAnonymous18:04 14 Apr '05  
QuestionHow can I set the submenuItem's Checked Status? Pinmemberhanll22:34 4 Jul '04  
AnswerRe: How can I set the submenuItem's Checked Status? Pinmemberhanll23:27 4 Jul '04  
GeneralThanks Pinmembersfalong2:46 25 Mar '04  
GeneralIcon resources PinmemberPPPDev5:57 9 Jan '04  
QuestionWhat does ModifyRegistry does? Pinmemberazusakt17:49 23 Oct '03  
QuestionMDIList feature lost? Pinmemberpingdee8:18 22 Oct '03  
GeneralHotkeyPrefix Pinmemberlagay12:53 8 Sep '03  
GeneralContext Menu and CloneMenu Method Pinmembermarianod2@hotmail.com9:12 22 Aug '03  
GeneralOffice 2003 Menu Style Pinmember8MX10:48 10 Apr '03  
GeneralRe: Office 2003 Menu Style PinmemberRay Cassick11:48 10 Apr '03  
GeneralBad Code PinmemberTemplMetaProg1:38 28 Mar '03  
GeneralRe: Bad Code Pinmember.S.Rod.1:58 28 Mar '03  
GeneralEqual Menuitem Name Pinmembermveiga16:37 23 Jan '03  
GeneralRe: Equal Menuitem Name Pinmemberlonelywind198217:33 6 Apr '06  

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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