<!-- Article image -->
<!-- Add the rest of your HTML here -->
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:
and after the "InitializeComponent()" code:
NiceMenu myNiceMenu = new NiceMenu();
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:
- 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!
This is an improvement by Francesco Natali over an improvement by Sajith M of the "Visual Studio .NET Menu Style" by Carlos H. Perez