Click here to Skip to main content
11,412,834 members (74,689 online)
Click here to Skip to main content

An easy way to add a Ribbon Panel Office 2007 style

, 18 Apr 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
GNU code of RibbonPanel, free software for personal and nonlucrative use, for rest please contact me
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Juan Pablo G.C.
Software Developer Expediteapps
Spain Spain
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

Deeply involved in Xamarin Forms LOB (including Azure Cloud with offline support, custom controls, dependencies) projects, WP8.1 & W10 projects, WPF modern styled projects. Portable libraries like portablePDF, portableOneDrive, portableReports and portablePrinting (using Google Printing API).


Web and apps showcase at:
Expediteapps


Take a look to my blog
Blog
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 5 Pin
jraju11421 at 23-Nov-11 23:15
memberjraju1142123-Nov-11 23:15 
GeneralMy vote of 5 Pin
SI_SHEN_001 at 25-Sep-11 22:22
memberSI_SHEN_00125-Sep-11 22:22 
GeneralMy vote of 5 Pin
vahidmir at 29-Jul-11 20:30
membervahidmir29-Jul-11 20:30 
GeneralMy vote of 5 Pin
Saumitra Kumar Paul at 31-May-11 21:22
memberSaumitra Kumar Paul31-May-11 21:22 
GeneralMy vote of 5 Pin
hadre at 11-May-11 21:31
memberhadre11-May-11 21:31 
QuestionRight to left layout Pin
salimdz2002 at 30-Apr-11 5:57
membersalimdz200230-Apr-11 5:57 
AnswerRe: Right to left layout [modified] Pin
behnam_jan at 6-Oct-11 3:16
memberbehnam_jan6-Oct-11 3:16 
GeneralMy vote of 5 Pin
hruday1234567 at 11-Feb-11 21:30
memberhruday123456711-Feb-11 21:30 
GeneralMy vote of 5 Pin
Mehdi Ghiasi at 9-Aug-10 2:07
memberMehdi Ghiasi9-Aug-10 2:07 
GeneralMy vote of 5 Pin
kiumarskahoori at 30-Jun-10 4:14
memberkiumarskahoori30-Jun-10 4:14 
GeneralContent Pin
dave52803 at 27-Jun-10 6:49
memberdave5280327-Jun-10 6:49 
GeneralHandling enablig/disabling button Pin
lkrfan at 16-Jun-10 11:11
memberlkrfan16-Jun-10 11:11 
GeneralError when running under .NET 4.0 Pin
Ianlo at 21-Apr-10 8:47
memberIanlo21-Apr-10 8:47 
GeneralMessage Automatically Removed Pin
at 7-Mar-10 6:57
memberMember 31108197-Mar-10 6:57 
GeneralPRoblem i can't import it to VS 2008 [modified] Pin
Michalss at 7-Jan-10 22:24
memberMichalss7-Jan-10 22:24 
GeneralRe: PRoblem i can import it to VS 2008 Pin
Michalss at 7-Jan-10 22:38
memberMichalss7-Jan-10 22:38 
GeneralRe: PRoblem i can import it to VS 2008 Pin
Jaime Stuardo at 8-Jan-10 16:14
memberJaime Stuardo8-Jan-10 16:14 
GeneralRe: PRoblem i can import it to VS 2008 Pin
Michalss at 8-Jan-10 23:18
memberMichalss8-Jan-10 23:18 
GeneralRe: PRoblem i can import it to VS 2008 Pin
tom1002 at 11-Aug-10 5:34
membertom100211-Aug-10 5:34 
QuestionMissing components, anyone knows where they are to be found? Pin
virtually_void at 24-Nov-09 23:25
membervirtually_void24-Nov-09 23:25 
AnswerRe: Missing components, anyone knows where they are to be found? Pin
Jaime Stuardo at 8-Jan-10 16:15
memberJaime Stuardo8-Jan-10 16:15 
GeneralRe: Missing components, anyone knows where they are to be found? Pin
keyur_patel at 6-Apr-12 11:00
memberkeyur_patel6-Apr-12 11:00 
Questioncan use in vb.net Pin
shekaraluwala at 12-Nov-09 6:05
membershekaraluwala12-Nov-09 6:05 
GeneralIssue using ribbon in MDI child form Pin
enrico.carretti at 15-Oct-09 10:12
memberenrico.carretti15-Oct-09 10:12 
Generalsome Child Form Color not changing Pin
sujit9923 at 28-Sep-09 23:11
membersujit992328-Sep-09 23:11 
GeneralNice.... Pin
gaferrero at 10-Sep-09 9:46
membergaferrero10-Sep-09 9:46 
GeneralLicence Pin
woofie at 16-Jul-09 22:58
memberwoofie16-Jul-09 22:58 
GeneralRe: Licence Pin
Paul Meems at 19-Oct-09 0:46
memberPaul Meems19-Oct-09 0:46 
GeneralNice! Pin
Gustavo Calonio at 8-Jul-09 2:33
memberGustavo Calonio8-Jul-09 2:33 
QuestionAdding to the toolbox [modified] cannot find assembly error: Pin
stixoffire at 24-Apr-09 1:47
memberstixoffire24-Apr-09 1:47 
QuestionRe: Adding to the toolbox [modified] cannot find assembly error: Pin
stixoffire at 17-May-09 19:18
memberstixoffire17-May-09 19:18 
GeneralA first chance exception of type 'System.ArgumentNullException' occurred in System.Drawing.dll Pin
fuzz007 at 22-Apr-09 19:31
memberfuzz00722-Apr-09 19:31 
QuestionHow can I convert this instruction in VB net? Pin
uastasi at 20-Apr-09 6:02
memberuastasi20-Apr-09 6:02 
AnswerRe: How can I convert this instruction in VB net? Pin
stixoffire at 20-Apr-09 19:04
memberstixoffire20-Apr-09 19:04 
QuestionRe: How can I convert this instruction in VB net? Pin
uastasi at 20-Apr-09 22:23
memberuastasi20-Apr-09 22:23 
AnswerRe: How can I convert this instruction in VB net? Pin
stixoffire at 21-Apr-09 4:54
memberstixoffire21-Apr-09 4:54 
AnswerRe: How can I convert this instruction in VB net? Pin
stixoffire at 21-Apr-09 5:00
memberstixoffire21-Apr-09 5:00 
QuestionVB.Net version? Pin
Tim8w at 3-Apr-09 8:52
memberTim8w3-Apr-09 8:52 
Questionvb.net Pin
hackreet at 18-Feb-09 15:01
memberhackreet18-Feb-09 15:01 
GeneralPainting Problems Pin
XaZaM at 18-Nov-08 9:53
memberXaZaM18-Nov-08 9:53 
Generali found how to add the control to toolbox Pin
hyunki85 at 22-Oct-08 3:25
memberhyunki8522-Oct-08 3:25 
Questionhow disable tooltip? Pin
vinycc1 at 16-Oct-08 11:22
membervinycc116-Oct-08 11:22 
AnswerRe: how disable tooltip? Pin
Jaime Stuardo at 8-Jan-10 16:24
memberJaime Stuardo8-Jan-10 16:24 
QuestionQAT?? Pin
kapil bhavsar at 24-Sep-08 21:33
memberkapil bhavsar24-Sep-08 21:33 
QuestionCan i use this in... Pin
Amrykid at 19-Sep-08 15:40
memberAmrykid19-Sep-08 15:40 
Questiondo it has VB.NET version? Pin
limsoochen at 29-Aug-08 0:33
memberlimsoochen29-Aug-08 0:33 
AnswerRe: do it has VB.NET version? Pin
kaschimer at 19-Nov-08 6:55
memberkaschimer19-Nov-08 6:55 
GeneralThe name 'TabStripControlLibrary' does not exist in the current context Pin
jacobjordan at 23-Aug-08 13:29
memberjacobjordan23-Aug-08 13:29 
QuestionShortCut key on ribbonButton? Pin
TaiZhong at 30-Jul-08 6:09
memberTaiZhong30-Jul-08 6:09 
Generalcustom ribbon ready for cute app Pin
radioman.lt at 3-Jul-08 20:36
memberradioman.lt3-Jul-08 20:36 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150427.1 | Last Updated 18 Apr 2007
Article Copyright 2007 by Juan Pablo G.C.
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid