Click here to Skip to main content
Licence 
First Posted 6 Dec 2006
Views 161,702
Downloads 1,758
Bookmarked 202 times

Office 2007 ToolStrip Renderer

By Phil. Wright | 6 Dec 2006
Use a custom tool strip renderer to achieve the Office 2007 look and feel.
1 vote, 1.4%
1

2
2 votes, 2.8%
3
6 votes, 8.5%
4
62 votes, 87.3%
5
4.91/5 - 71 votes
3 removed
μ 4.71, σa 1.09 [?]

Sample Image

Introduction

With the release of Office 2007, you will want to update your applications with the latest look and feel. With .NET 2.0, this is a simple process as you just need to use this custom renderer for the ToolStrip manager. Assign the custom renderer to the ToolStripManager.Renderer property, and it will customize the appearance of all ToolStrip, MenuStrip, StatusStrip, and ContextMenuStrip instances in your application.

Using the Custom Renderer

To make use of the custom renderer, you need to hook into the Load event of your Form. Just double click the form at design time to have the event handler for the Load event auto generated. Then, you need to add just this single line of code...

private void Form1_Load(object sender, EventArgs e)
{
   ToolStripManager.Renderer = new Office2007Renderer();
}

There are a couple of other steps you might need to take at design time. If you are using a StatusStrip, then you need to update the render mode because, by default, it will not use the global one specified in the line of code above. So for each StatusStrip, you just need to click the smart tag and set the RenderMode to be ManagerRenderMode. Likewise for any ToolStripContainer that is created, just left click in the center of the container area, and then look in the Properties window for the RenderMode and again change it to ManagerRenderMode.

Points of Interest

I would have made the context menu have rounded corners just like Office 2007, but this is not possible because of the way the tool strips have been implemented. The background of the context menu is always drawn in a color that takes up the entire client area of the popup window. So it was not possible to simulate a rounded corner by not drawing the corner pixels. I could not find a way to set a region for the popup window either. Maybe someone else will have better luck.

History

This custom renderer was created as part of the development process of adding the Office 2007 appearance to the Krypton Toolkit. The Krypton Toolkit is a free set of controls for .NET 2.0 Windows Forms applications. It implements the full Office 2007 appearance for all of its controls including buttons, panels, headers, and so forth. You can download the free toolkit from here.

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

Phil. Wright



United Kingdom United Kingdom

Member
Founder of Component Factory and currently working on developing professional user interface controls for VS2005 and .NET2.
 
You can check out our Krypton Toolkit free library at http://www.componentfactory.com/products.php

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

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionI need your permission PinmemberMaximilianReisch2:33 10 Oct '10  
GeneralMy vote of 5 PinmemberISharp0:03 30 Aug '10  
GeneralDisabled image contextMenu issue Pinmemberborchanii2:42 14 Jul '09  
QuestionLicensing inquiry Pinmember2twotango3:04 10 Feb '09  
GeneralText Color PinmemberMember 19405985:25 3 Oct '08  
GeneralVb2008 version of Office2007Renderer... no MenuItembackground Pinmemberdherrmann0:26 12 Jun '08  
GeneralRe: Vb2008 version of Office2007Renderer... no MenuItembackground PinmemberAngleV1:30 22 Jun '08  
GeneralRe: Vb2008 version of Office2007Renderer... no MenuItembackground PinmemberAngleV3:28 22 Jun '08  
GeneralSmall bug... Pinmemberpimb23:28 7 May '08  
QuestionAnother bug? Pinmemberlextm19:43 17 Feb '08  
GeneralTo prevent background flicker... PinmemberJeremyHill16:43 3 Jan '08  
Hi,
 
Very nice-looking renderer.
 
One small detail, in:
 
OnRenderToolStripContentPanelBackground
 
where you comment:
 
// Must call base class, otherwise the subsequent drawing does not appear!
 
Actually, you will not need this call - and you will eliminate the heavy background flicker - if you properly set e.Handled to true when you have painted it yourself.
 
Cheers,
 
JD
GeneralGreat Component PinmemberChuck Catron9:49 20 Sep '07  
GeneralYou can check out our Krypton Toolkit free library at .... Pinmembercaddzooks2:32 21 Aug '07  
GeneralRe: You can check out our Krypton Toolkit free library at .... PinmemberAbsCode8:00 21 Aug '07  
GeneralRe: You can check out our Krypton Toolkit free library at .... PinmemberComponentPhil16:28 21 Aug '07  
QuestionHow about licence? Pinmemberosvaldas_briedis4:07 6 Aug '07  
GeneralRe: How about licence? Pinmemberlextm3:21 22 Feb '08  
GeneralRe: How about licence? PinmemberMaximilianReisch2:36 10 Oct '10  
GeneralRe: How about licence? PinmemberMaximilianReisch2:37 10 Oct '10  
QuestionRender tab Pinmemberthachvv186:38 24 Jul '07  
AnswerRe: Render tab Pinmemberjpmsoft16:10 14 Jul '08  
Questionslow draw Pinmemberthachvv189:20 17 Jul '07  
Questionhow to renderer progressbar on status strip Pinmemberafaz4:03 5 Jun '07  
AnswerRe: how to renderer progressbar on status strip PinmemberKoaQiu22:53 5 Jun '07  
GeneralUsing Office 2007 ToolStrip Rendere in CodePlex projects Pinmembermarco.minerva23:40 23 May '07  

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

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120210.1 | Last Updated 6 Dec 2006
Article Copyright 2006 by Phil. Wright
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid