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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralGreat tool. Beware if you re using multiple context menuesmemberanton_fernando25 Jun '07 - 10:29 
GeneralConverting to Visual Studio 2005 ToolStripMenuItemmemberVeeran Kutty31 Jan '06 - 7:38 
GeneralConvenient click handler for menumemberCoreyRIT6 Jan '06 - 7:58 
GeneralRe: Convenient click handler for menumemberanton_fernando23 May '06 - 9:55 
GeneralAdding a Windows Form to a menumemberJim Barber27 Aug '05 - 19:18 
Hello...
 
I just got in to c#.net and love it. But, I'm still virgin to this language. I have created a project that has several forms in it other than the main form. For example: I have a form call frmMain and it wants to call a form call AboutBox from the main menu.
 
Question is, HOW? I'm a visual studio programmer and I can't for the life of me figure out how to call the form. I tried using Application.Run(AboutBox()); and that doesn't work.
 
Can you give me a heads up on this simple question?
 
Thanx in advance.
 
Jim Barber
qsoft@comcast.net
AnswerRe: Adding a Windows Form to a menumemberillium31 Jul '06 - 18:45 
Generalsubmenu arrowmemberSoTTo27 Jun '05 - 4:45 
QuestionMC++ ?memberCppBeginner9 Oct '04 - 0:55 
QuestionEnabled works??membermpwt17 Sep '04 - 0:58 
Generalvery nice toolmembersherb13 Sep '04 - 2:19 
GeneralRe: very nice toolsussAnonymous14 Apr '05 - 18:04 
QuestionHow can I set the submenuItem's Checked Status?memberhanll4 Jul '04 - 22:34 
AnswerRe: How can I set the submenuItem's Checked Status?memberhanll4 Jul '04 - 23:27 
GeneralThanksmembersfalong25 Mar '04 - 2:46 
GeneralIcon resourcesmemberPPPDev9 Jan '04 - 5:57 
QuestionWhat does ModifyRegistry does?memberazusakt23 Oct '03 - 17:49 
QuestionMDIList feature lost?memberpingdee22 Oct '03 - 8:18 
GeneralHotkeyPrefixmemberlagay8 Sep '03 - 12:53 
GeneralContext Menu and CloneMenu Methodmembermarianod2@hotmail.com22 Aug '03 - 9:12 
GeneralOffice 2003 Menu Stylemember8MX10 Apr '03 - 10:48 
GeneralRe: Office 2003 Menu StylememberRay Cassick10 Apr '03 - 11:48 
GeneralBad CodememberTemplMetaProg28 Mar '03 - 1:38 
GeneralRe: Bad Codemember.S.Rod.28 Mar '03 - 1:58 
GeneralEqual Menuitem Namemembermveiga23 Jan '03 - 16:37 
GeneralRe: Equal Menuitem Namememberlonelywind19826 Apr '06 - 17:33 
GeneralVB .NETmemberjadeboy17 Jan '03 - 1:03 
Generalsome proplemmemberchinadeer11 Jan '03 - 2:32 
GeneralRe: some proplemmemberFrancesco Natali15 Jan '03 - 5:46 
GeneralRe: some proplemmemberzhuhai16 Dec '03 - 15:04 
GeneralRe: some proplemmembershinji8111 Oct '04 - 11:28 
GeneralCool But...memberhouda14 Dec '02 - 11:34 
GeneralcoolmemberJusin3 Dec '02 - 5:29 
Question.net menu?memberrang3r3 Dec '02 - 3:10 
AnswerRe: .net menu?memberFayez Al-Naddaf3 Dec '02 - 8:12 
GeneralRe: .net menu?memberKishorerc23 Dec '02 - 20:58 
GeneralRe: .net menu?sussKmaster17 Jan '03 - 15:48 
GeneralRe: .net menu?memberdnh26 Jun '04 - 11:04 

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

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