Click here to Skip to main content
15,888,610 members
Articles / Programming Languages / XML

Office 2003 Menus

Rate me:
Please Sign up or sign in to vote.
4.74/5 (70 votes)
23 Feb 20042 min read 336.9K   1.5K   113   82
A component to change the look of the menus to that of Office 2003

Introduction

Just with one Single Line of code, you can change the look of all Menus and Context menus of your Windows Forms Project to look just like the menus shipped with Office 2003. Also, you can add Icons to your menus with a single line of code. There is one more feature in this component, You can simply call the method End to change the menus to its original look.

Using the Code

To use the Component, first, add the component to the Toolbox, and then drag it to the form, and then just call this method:

C#
// To start showing the Office 2003 Menus
OfficeMenus1.Start( FormName );

Also, you can change the look of the menus to its original look by calling this method:

C#
// to change the look of the menus to its original "classic" look
OfficeMenus1.End();

Adding Icons to Menu Items is very simple. Just add an ImageList to your project, and then change the ImageList property of your OfficeMenu Component to the ImageList you wish to use, and then use this code:

C#
// Adding a picture to your Menus
// OfficeMenus.AddPicture( MenuItem MenuItemToAddPictureTo, int ImageIndex );
OfficeMenus1.ImageList = imageList1;
OfficeMenus1.AddPicture(menuItem2, 1);

Points of Interest

I was so confused about the way in which I will add pictures to menus, so I decided to add a collection of type NameValueCollection, and when we call the method AddPicture, it will add the Handle of the menu and the Image index to that Collection, and when we want to retrieve the image of a menu, we search this collection for the handle of the menu, if found, it returns the picture, otherwise it returns null. Check the code for more information. BTW, the code is well commented.

18th October, 2006: There is a problem when using this control under MDI application, the menuitem added by MDI application automatically can't take effect.

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.


Written By
Saudi Arabia Saudi Arabia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: MDI support Pin
cnhawk28-Nov-07 18:30
cnhawk28-Nov-07 18:30 
GeneralMore bugs.... Pin
JoePeavey24-Jun-04 7:13
JoePeavey24-Jun-04 7:13 
GeneralGreat Control: Small bug with context menus Pin
JoePeavey23-Jun-04 10:38
JoePeavey23-Jun-04 10:38 
GeneralRe: Great Control: Small bug with context menus Pin
Supergoal8-Apr-05 4:09
Supergoal8-Apr-05 4:09 
Questionhow can i do Pin
hoaian16-Jun-04 22:08
hoaian16-Jun-04 22:08 
QuestionWindowsFormsParkingWindow bug? Pin
Kevin C27-May-04 10:53
Kevin C27-May-04 10:53 
AnswerRe: WindowsFormsParkingWindow bug? Pin
Mathieu Frenette19-Sep-04 8:47
sussMathieu Frenette19-Sep-04 8:47 
GeneralIt is good! Pin
cmdsh26-May-04 21:31
cmdsh26-May-04 21:31 
QuestionAbout the menu text !!! The bug??? Pin
usxue23-May-04 20:11
usxue23-May-04 20:11 
GeneralSPAMMER Pin
abhadresh2-May-04 16:33
abhadresh2-May-04 16:33 
QuestionHow to make the Menu bar Office 2003 look Pin
TaoLi27-Apr-04 5:02
TaoLi27-Apr-04 5:02 
AnswerRe: How to make the Menu bar Office 2003 look Pin
coder4rent5-May-04 8:50
coder4rent5-May-04 8:50 
AnswerRe: How to make the Menu bar Office 2003 look Pin
Aaron Eldreth11-May-04 8:11
Aaron Eldreth11-May-04 8:11 
GeneralRe: How to make the Menu bar Office 2003 look Pin
Anonymous12-Oct-04 18:40
Anonymous12-Oct-04 18:40 
GeneralThanks for this code! I've made some changes... Pin
Meff22-Apr-04 10:55
Meff22-Apr-04 10:55 
GeneralContext menu in child form does not work Pin
maihuaz7-Mar-04 2:53
maihuaz7-Mar-04 2:53 
GeneralRe: Context menu in child form does not work Pin
Mohammed Halabi7-Mar-04 5:00
Mohammed Halabi7-Mar-04 5:00 
GeneralRe: Context menu in child form does not work Pin
DavidNohejl28-Jun-04 9:09
DavidNohejl28-Jun-04 9:09 
GeneralGreat work but a small bug and missing features Pin
elp?5-Mar-04 4:58
elp?5-Mar-04 4:58 
GeneralBrilliant piece of work Pin
Chris_S26-Feb-04 9:32
Chris_S26-Feb-04 9:32 
GeneralNotifyIcon does not display menu!!! Pin
Marcin G26-Feb-04 7:56
Marcin G26-Feb-04 7:56 
GeneralRe: NotifyIcon does not display menu!!! Pin
Marcin G26-Feb-04 10:21
Marcin G26-Feb-04 10:21 
GeneralRe: NotifyIcon does not display menu!!! Pin
Marcin G2-Mar-04 5:21
Marcin G2-Mar-04 5:21 
GeneralShortcuts not the same.... Pin
Ellery_Familia24-Feb-04 9:30
Ellery_Familia24-Feb-04 9:30 
GeneralRe: Shortcuts not the same.... Pin
Mohammed Halabi24-Feb-04 11:35
Mohammed Halabi24-Feb-04 11:35 

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

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