Click here to Skip to main content
Licence 
First Posted 18 Apr 2007
Views 365,668
Downloads 8,346
Bookmarked 487 times

An easy way to add a Ribbon Panel Office 2007 style

By Juan Pablo G.C. | 18 Apr 2007
GNU code of RibbonPanel, free software for personal and nonlucrative use, for rest please contact me
Prize winner in Competition "Best C# article of Mar 2007"
8 votes, 3.2%
1
2 votes, 0.8%
2
4 votes, 1.6%
3
16 votes, 6.5%
4
217 votes, 87.9%
5
4.93/5 - 248 votes
14 removed
μ 4.77, σa 1.42 [?]
Screenshot - overview.jpg

Introduction

A picture is worth a thousand words, well it was a really cute work at the end. Before explaining how to add it to your applications, I will show you the main features.

Features of RibbonStyle Namespace

  • RibbonButton: Transparency, Autosizable image, AutoForecolor, AutoInfoForm (see InfoForm, OnBackImage and ClickBackImage).
  • TabPanel: Transparency, BaseColor, BaseColorOn (Highlighted), Caption, Resizable.
  • TabStrip: Has inside:
    1. Tab: With Autowidth, BaseColor, HaloColor and Enable work.
    2. TabStripProffesionalRenderer: Controls the Tab Style (hard to work)
    3. TabStripPage: BaseColor, inherits my RibbonPanel.
    4. TabPageSwitcher: Controls the link between Tab and TabStripPage. Design functionality as the tabcontrol.
  • InfoForm (with Shadow): Depending on Title, Comment, and Image of Info.. Properties of RibbonButton resizes itself.

Using the controls

I hope that if you have understood the Features, the next will be easy for you.

  1. Make a new C# App.
  2. Add all the classes to your app.
  3. Now Rebuild the project.
  4. In the toolbox you will have many new controls:

    Screenshot - toolbox.jpg

  5. Now Add a Windows.Forms.Panel to the Form and dock to the top, adjust it like you want.
  6. Add the TabStrip inside the Panel.
  7. With the TabStripPageSwitcher you can add TabStrip. If you find it difficult to click on it, you can click in the properties window:
  8. Screenshot - tabpageswitcher.jpg

  9. With a TabStrip and some tabs and TabStrip pages, add TabPanels inside the TabStripPages (Check the TabPanel has BackColor.Transparent) . I recommend you to add a few of them to the form and copy and paste inside the tabStripPage (it is easy to dock them later). With the Tabpanels added, dock them to the left.
  10. Now add the RibbonButton inside the TabPanel, adjust its size and its images, copy and paste as you want and change the image. Don't worry about the text colors, they will be processed at runtime.
  11. If everything is ok and if you run it, you will see something like this (Azure Style):

    Screenshot - tabs.jpg

Creating your custom style

As you could see in the demo zip, it is possible to change the colors at runtime. Let's analyze the code. If you look at the Form1 code, there's a method SetStyle:

public void SetStyle(string Name)
{
    Color HaloColor = Color.White;
    switch (Name)
    {
        case "Dark":
        this.BackColor = Color.FromArgb(88,77,69);
        HaloColor = Color.FromArgb(200,200,200);
        SetBase(87,61,53,HaloColor);
    break;...

You find out that you have to change only three colors! I hope you find it useful. The rest are sum or subs from the color components. So to avoid color errors, I recommend taking a look at my other article which has a color selector, only for the basecolor, HaloColor is the brightness over the tabs and the Backcolor is for the form.

Points of Interest

I have to say that I use the base of CustomTabstrip for the part of tabstrip. I was annoyed with the tabcontrol and after looking for something, the best was to inherit from a ToolStrip.

There's a lot of code in the project and I have written this with a lot of effort. If you need an explanation of any part, please ask me. It's .NET 2.0 code I put in a Windows 2000 machine and it works really well in XP and Vista too.

To design a better software, please vote the value of the code for you and if you vote, please tell me the pros and cons.

History

  • 1.0: The first version of the control library.

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

Juan Pablo G.C.

Software Developer

Spain Spain

Member
I'm Electronic Engineer, I did my end degree project at Astrophysical Institute and Tech Institute. I'm HP Procurve AIS and ASE ,Microsoft 3.5 MCTS
I live in Canary Islands ,developing customized solutions
 
I'm developing with WPF4, SL4 MVVM, MVC3 Razor and WP7 projects, more info at my websites. Improving with Android and IOS.
 
Websites:
MemCards
Mareinsula


Take a look to my blog Juan Pablo G.C.
Mareinsula

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
GeneralMy vote of 5 Pinmemberjraju1142123:15 23 Nov '11  
GeneralMy vote of 5 PinmemberSI_SHEN_00122:22 25 Sep '11  
GeneralMy vote of 5 Pinmembervahidmir20:30 29 Jul '11  
GeneralMy vote of 5 PinmemberSaumitra Kumar Paul21:22 31 May '11  
GeneralMy vote of 5 Pinmemberhadre21:31 11 May '11  
QuestionRight to left layout Pinmembersalimdz20025:57 30 Apr '11  
AnswerRe: Right to left layout [modified] Pinmemberbehnam_jan3:16 6 Oct '11  
GeneralMy vote of 5 Pinmemberhruday123456721:30 11 Feb '11  
GeneralMy vote of 5 PinmemberMehdi Ghiasi2:07 9 Aug '10  
GeneralMy vote of 5 Pinmemberkiumarskahoori4:14 30 Jun '10  
GeneralContent Pinmemberdave528036:49 27 Jun '10  
GeneralHandling enablig/disabling button Pinmemberlkrfan11:11 16 Jun '10  
GeneralError when running under .NET 4.0 PinmemberIanlo8:47 21 Apr '10  
Generaloutlook sidebar PinmemberMember 31108196:57 7 Mar '10  
GeneralPRoblem i can't import it to VS 2008 [modified] PinmemberMichalss22:24 7 Jan '10  
GeneralRe: PRoblem i can import it to VS 2008 PinmemberMichalss22:38 7 Jan '10  
GeneralRe: PRoblem i can import it to VS 2008 PinmemberJaime Stuardo16:14 8 Jan '10  
GeneralRe: PRoblem i can import it to VS 2008 PinmemberMichalss23:18 8 Jan '10  
GeneralRe: PRoblem i can import it to VS 2008 Pinmembertom10025:34 11 Aug '10  
QuestionMissing components, anyone knows where they are to be found? Pinmembervirtually_void23:25 24 Nov '09  
AnswerRe: Missing components, anyone knows where they are to be found? PinmemberJaime Stuardo16:15 8 Jan '10  
Questioncan use in vb.net Pinmembershekaraluwala6:05 12 Nov '09  
GeneralIssue using ribbon in MDI child form Pinmemberenrico.carretti10:12 15 Oct '09  
Generalsome Child Form Color not changing Pinmembersujit992323:11 28 Sep '09  
GeneralNice.... Pinmembergaferrero9:46 10 Sep '09  

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
Web01 | 2.5.120209.1 | Last Updated 18 Apr 2007
Article Copyright 2007 by Juan Pablo G.C.
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid