Click here to Skip to main content
15,881,898 members
Articles / Desktop Programming / Windows Forms
Article

An easy way to add a Ribbon Panel Office 2007 style

Rate me:
Please Sign up or sign in to vote.
4.93/5 (252 votes)
18 Apr 2007CPOL3 min read 822.9K   26.7K   521   263
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:

C#
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)


Written By
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

Comments and Discussions

 
AnswerRe: Can anyone get this to work? And how can you use it with VB.Net? Pin
c95se5m27-Jul-07 7:53
c95se5m27-Jul-07 7:53 
QuestionRe: Can anyone get this to work? And how can you use it with VB.Net? [modified] Pin
dawmail33327-Jul-07 11:47
dawmail33327-Jul-07 11:47 
AnswerRe: Can anyone get this to work? And how can you use it with VB.Net? Pin
Moshe23983289327-Jul-07 13:52
Moshe23983289327-Jul-07 13:52 
AnswerRe: Can anyone get this to work? And how can you use it with VB.Net? Pin
Moshe23983289327-Jul-07 13:54
Moshe23983289327-Jul-07 13:54 
Generalawsome :) Pin
deltadirac24-Jul-07 11:57
deltadirac24-Jul-07 11:57 
GeneralRe: awsome :) Pin
Juan Pablo G.C.25-Jul-07 2:32
Juan Pablo G.C.25-Jul-07 2:32 
GeneralRe: awsome :) Pin
deltadirac27-Jul-07 10:10
deltadirac27-Jul-07 10:10 
QuestionGreat Work and a question for usage of icons Pin
jdem22-Jul-07 0:08
jdem22-Jul-07 0:08 
AnswerRe: Great Work and a question for usage of icons Pin
Juan Pablo G.C.22-Jul-07 7:17
Juan Pablo G.C.22-Jul-07 7:17 
GeneralGreat Job! And I have done a lit bit change Pin
luyuxun17-Jul-07 18:08
luyuxun17-Jul-07 18:08 
GeneralRe: Great Job! And I have done a lit bit change Pin
qwertz u21-Jul-07 1:45
qwertz u21-Jul-07 1:45 
GeneralBrillian work! Pin
brianmayclone16-Jul-07 10:55
brianmayclone16-Jul-07 10:55 
QuestionSystem.Design not found Pin
hinerasky13-Jul-07 11:15
hinerasky13-Jul-07 11:15 
AnswerRe: System.Design not found Pin
benito.lopez.d19-Jul-07 18:52
benito.lopez.d19-Jul-07 18:52 
QuestionError in displaying color of tab Pin
thachvv1810-Jul-07 5:58
thachvv1810-Jul-07 5:58 
AnswerRe: Error in displaying color of tab Pin
remistp10-Jul-07 7:30
remistp10-Jul-07 7:30 
GeneralRe: Error in displaying color of tab Pin
c95se5m27-Jul-07 8:12
c95se5m27-Jul-07 8:12 
Generalconvert to vb.Net Pin
Tom Deketelaere10-Jul-07 2:42
professionalTom Deketelaere10-Jul-07 2:42 
GeneralTab Color & Control does not have usable component Pin
big_bruiser3-Jul-07 10:20
big_bruiser3-Jul-07 10:20 
Questionhow to select item from code? Pin
silver snail1-Jul-07 3:54
silver snail1-Jul-07 3:54 
AnswerRe: how to select item from code? Pin
Greco Shi2-Jul-07 22:56
Greco Shi2-Jul-07 22:56 
GeneralRe: how to select item from code? Pin
silver snail3-Jul-07 1:14
silver snail3-Jul-07 1:14 
GeneralLicense on commercial app Pin
jprubio29-Jun-07 0:08
jprubio29-Jun-07 0:08 
GeneralError adding controls to toolbox Pin
Ed.Poore17-Jun-07 12:38
Ed.Poore17-Jun-07 12:38 
GeneralRe: Error adding controls to toolbox Pin
joaoalbertofn27-Jun-07 2:29
joaoalbertofn27-Jun-07 2:29 

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.