Click here to Skip to main content
15,881,866 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.5K   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: for hotkey Pin
Thomas-H.24-Mar-05 1:04
Thomas-H.24-Mar-05 1:04 
GeneralRe: for hotkey Pin
Nguyen Le24-Mar-05 5:10
Nguyen Le24-Mar-05 5:10 
GeneralRe: for hotkey Pin
Thomas-H.28-Mar-05 21:50
Thomas-H.28-Mar-05 21:50 
GeneralRe: for hotkey Pin
amoba22-Sep-05 3:19
amoba22-Sep-05 3:19 
GeneralRe: for hotkey Pin
charliedurrant9-Nov-05 3:39
charliedurrant9-Nov-05 3:39 
GeneralRe: for hotkey Pin
hcihlen4-Sep-05 2:20
hcihlen4-Sep-05 2:20 
GeneralRe: for hotkey Pin
Dutchpower28-Sep-05 1:43
Dutchpower28-Sep-05 1:43 
GeneralTo add the hotkey when you prefix a leffer by '&' Pin
andrei_t325-Jul-07 23:42
andrei_t325-Jul-07 23:42 
GeneralI discovers this website is very slow Pin
qihontin1-Mar-05 18:29
qihontin1-Mar-05 18:29 
Generalit throws an error. Pin
Pyro Joe30-Dec-04 6:00
Pyro Joe30-Dec-04 6:00 
GeneralRe: it throws an error. Pin
Pyro Joe30-Dec-04 6:44
Pyro Joe30-Dec-04 6:44 
Questionwhere do you the find the OfficeMenus object? Pin
Pyro Joe30-Dec-04 5:48
Pyro Joe30-Dec-04 5:48 
AnswerRe: where do you the find the OfficeMenus object? Pin
Pyro Joe30-Dec-04 6:03
Pyro Joe30-Dec-04 6:03 
AnswerRe: where do you the find the OfficeMenus object? Pin
spvarapu30-Apr-05 21:51
spvarapu30-Apr-05 21:51 
GeneralNested controls bug and a solution Pin
horvatma16-Dec-04 0:14
horvatma16-Dec-04 0:14 
GeneralRe: Nested controls bug and a solution Pin
DDISoft21-Mar-05 11:11
DDISoft21-Mar-05 11:11 
GeneralRe: Nested controls bug and a solution Pin
Rasta Man5-Apr-05 18:04
Rasta Man5-Apr-05 18:04 
GeneralRe: Nested controls bug and a solution Pin
vutrunghieu31-Jul-05 6:03
vutrunghieu31-Jul-05 6:03 
QuestionIs Bug? Pin
feitian7812-Nov-04 17:41
feitian7812-Nov-04 17:41 
AnswerRe: Is Bug? Pin
Supergoal8-Apr-05 4:15
Supergoal8-Apr-05 4:15 
GeneralBug?! No Menu -> no Office 2003 for ContextMenu Pin
snoova the wookie27-Oct-04 6:02
snoova the wookie27-Oct-04 6:02 
GeneralThanks for your control Pin
XTV3-Sep-04 0:28
XTV3-Sep-04 0:28 
GeneralSeperators not visible Pin
umair8215-Aug-04 7:42
umair8215-Aug-04 7:42 
GeneralRe: Separators not visible Pin
Alexander German15-Nov-04 4:56
Alexander German15-Nov-04 4:56 
GeneralMDI support Pin
uTILLIty13-Aug-04 3:07
uTILLIty13-Aug-04 3:07 

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.