By Francesco Natali
This is an article that makes a few improvements over the "Visual Studio .NET Menu Style" by
Carlos H. Perez and Sajith M.
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 now your menu 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.
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:
1. add an imagelist control in your form
2. add your icons in your imagelist control
3. add in your menu items the index of the icon in the first two
characters. For example:
00New
01Open
02Close
4. After the "NiceMenu myNiceMenu = new NiceMenu();" code you have to
add this simple line of code:
myNiceMenu.imgMenu = nameofyourimagelist;
-----------------------------------------
NiceMenu.cs
prjNiceMenu.zip
