Click here to Skip to main content
Click here to Skip to main content

A Professional Ribbon You Will Use (Now with orb!)

By , 12 Jun 2012
 
Prize winner in Competition "Best C# article of May 2008"

New: Read the guide for embedding the ribbon on the non-client area.

WinFormsRibbon/ribbon_0.4.008.jpg

Introduction

Because of the lack of good free Ribbon controls on the web, I decided to write one myself. I've analyzed previous work on ribbon-controls, including those on CodeProject. Unfortunately, most existent controls are merely bad tries. Why? well, some lack nice rendering, some lack resizing features, some lack almost everything. Of course, well developed Ribbon controls are available at a price. This ribbon is free.

Why not WPF? Well mainly, because I needed the Ribbon to add it to my existing WinForms applications. In my opinion (the short version) this is not a "no" to WPF, is just a "not yet". Anyway, you can host a WinForms control in WPF (See this link).

Some of the Design Goals

Performance - This ribbon is contained on a Control window, and every element inside of it is managed as a bunch of bounds inside the control, just as the ToolStrip control does. Although this is difficult to manage from the ribbon's inside code, this is a way to keep it at the best performed ribbon. Believe me, download the demo, run it and resize the window. It performs beautifully.

Consistency with Office's Ribbon - I read once about Jakob Nielsen saying that most users prefer that the programs they use look just like Word, Excel or PowerPoint. This is quite obvious, because people use this software every day. Providing visual consistency with the Office's ribbon is very important because of that, people already know what to expect and that's a usability advantage. I've tried to see that every element in the ribbon looks and behaves exactly like it does in the Office's ribbon.

Ease of use for programmers - The naming of components is consistent with most WinForms naming system, even more with the ToolStrip elements. Property, event and method names for similar elements are named just like in the ToolStrip technology items.

Designer support - I will be adding more and more designer support so you can manage the ribbon 100% from the designer. Give it a try.

I will be providing updates and fixes for bugs, as I discover them or you kindly let me know about them.

Using the Ribbon

The ribbon is located in the System.Windows.Forms namespace, just as every other control, I think it's annoying to use controls named as MyCoolFirm.MyCoolNameSpace.MyCoolSubNameSpace and so on (Please do that only for business objects).

You can add a reference to the compiled DLL: System.Windows.Forms.Ribbon.dll or you can directly copy the source files to a folder on your project. The code is currently designed so you can just copy the source files, it doesn't need any extra resources.

Hands on: Quick Guide

The ribbon is composed mainly by three kind of elements, the tabs, the panels on the tabs (other developers call them groups) and the items inside the panels.

WinFormsRibbon/ribbontab.gif

WinFormsRibbon/ribbonpanel.gif

WinFormsRibbon/ribbonitems.gif

These elements are represented by RibbonTab, RibbonPanel and RibbonItem types. RibbonItem is an abstract class that provides basic functionality for any item hosted on a RibbonPanel or on a RibbonDropDown.

You can add tabs from the smart tag of the Ribbon, you can add panels to the tab by selecting the tab and calling the "AddPanel" verb on the bottom part of the property grid.

The elements on the ribbon are resized according to the available space for the ribbon. This is a key feature of the ribbon. It tries to bring all possible commands to the screen by resizing them, instead of hiding them on an overflow button like the old ToolStrip.

I treat this as three kinds of sizes: Large, Medium and Compact. An additional size is used for panels because panels can be collapsed, and then they will adopt the Overflow size.

WinFormsRibbon/ribbonpanelsizes.gif

Note: There's no way to directly affect the bounds of the elements on the ribbon, the size will always be determined the layout engine inside the ribbon. In fact, the layout depends on two factors: the available horizontal space on the ribbon and the size modes on the items.

If there's no available space on the ribbon for a panel, panel will be collapsed. If all panels are collapsed and space is not available yet, a scroll button will appear so user can scroll the panels horizontally.

Click to enlarge image

Buttons

There's only one type of button: RibbonButton. It can be set to three styles:

WinFormsRibbon/ribbonbuttonstyles.gif

RibbonButton adds the SmallImage property so you can set the image shown when button is in medium or compact mode. Although it's not restricted by functionality, it's highly recommended to use just 32 x 32 pixels for Image property and 16 x 16 for SmallImage property. Results are unexpected when sizes are different.

Note: Use the DropDownItems property to add items to the dropdown of the button.

The appearance of the buttons vary through size modes.

ItemGroups

The buttons like those on the Font and Paragraph panels are RibbonButton buttons hosted inside a RibbonItemGroup group.

WinFormsRibbon/ribbonitemgroup.gif

Items added to RibbonItemGroup will always be measured and treated in compact size mode.

Important: If a RibbonPanel will host RibbonItemGroup objects, you must set the RibbonPanel.FlowsTo property to Right. The layout on those items are treated differently because groups flow as rows.

Lists

Lists are represented by RibbonButtonList and provide two collections: Buttons and DropDownItems. This is because the list can be scrolled on the ribbon and can dropdown more items. The dropdown of list supports resizing by a grip on the south east corner.

If you want the buttons on the list to be shown on the dropdown, you will have to explicitly add another list with those buttons to the DropDownItems property.

Separators

Separators are represented by RibbonButtonSeparator and provides the well known separator functionality. When in a dropdown, separators can actually contain text. When they contain text, they will be rendered differently.

WinFormsRibbon/ribbondropdown.gif

Tutorials

  • Getting Started With the Ribbon at ribbon.codeplex.com 

Known Bugs

  • Multiple dropdowns not managed OK 
  • Drawing of collapsed panels when mouse down

Things To Do

  • Contextual tabs
  • ToolTips
  • (OK) TextBox, ComboBox
  • Checkbox and NumericUpDown RibbonItems
  • Orb and Quickaccess tools
  • Vista clientarea docking
  • Keyboard quick access through Alt key
  • Font and Color selectors
  • Right to left orientation
  • Ribbon minimization

History

  • 8 May 2008 - Original post
  • 29 May 2008 - Update
    • Enabled property now working
    • Added RibbonTextBox - A regular textbox with label and image
    • Added RibbonComboBox - (Inherited from RibbonTextBox) Offers a dropdown
    • Added RibbonColorChooser - A button that shows a color bar. See property Color
  • 23 Feb 2009 - Update
    • Orb and orb menu with designer capabilities
    • Quick Access Toolbar added
    • Some bugs fixed
  • 1 May 2009 - Update 
    • Orb and Quick access embedded on non-client area
    • Popup menus fixed!
    • Lots of Event handlers supported
    • Minor bugs fixed

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

About the Author

Jose Menendez Póo
Team Leader
Mexico Mexico
Member
Jose Manuel Menéndez Poó
 
- I've been programming Windows and Web apps since 1997.
- My greatest concern nowadays is user interface usability.
 
Questions and stuff by twitter: @menendezpoo
 
Jose Runs Goplek in Mexico
www.goplek.com
 
Blog
menendezpoo.com

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.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionCongratulations!memberKemuel Sanchez28 Apr '13 - 7:43 
Wow, I was really impressed with the quality of this project, and seeing that the author is a fellow latin american makes me proud! Congratulations, you made a fantastic work with this *FREE* contribution!
QuestionRight to left not workingmemberesaaco11 Mar '13 - 0:36 
when i try right to left not change on ribbon
plz help
AnswerRe: Right to left not workingmemberAlex Essilfie20 Mar '13 - 6:47 
It appears the developer has stopped working on this project.
Another group has taken up the project and are working on it here[^].
You may want to take a look at that instead.
AnswerRe: Right to left not workingmembertoATwork21 Apr '13 - 0:16 
Or if you prefer CodeProject:
Easily Add a Ribbon into a WinForms Application (C#)[^]
Questionso coooolmemberlhcxx22 Feb '13 - 8:13 
I just need it, so coool ,thx man
NewsFurther SupportmembertoATwork7 Feb '13 - 23:22 
It seems that support has stopped on this project.
If you are looking for further assistance or even a newer version please check this spin-off:
Easily Add a Ribbon into a WinForms Application (C#)[^]
 
Many thanks to Jose!
GeneralMy vote of 5memberAftPeakTank6 Feb '13 - 5:48 
Very good Performance and Design!
SuggestionOffice 2010 / 2013 StylememberVanlalruata3 Feb '13 - 2:39 
It would be nice to have even Office 2010 / 2013 format. Wink | ;-)
 
Thanks anyway!! Laugh | :laugh: Laugh | :laugh: Laugh | :laugh:
 
Thumbs Up | :thumbsup: Thumbs Up | :thumbsup: Thumbs Up | :thumbsup: Java | [Coffee]
ZoSoft Network

QuestionThank you to sharememberkongQiang27 Jan '13 - 15:08 
Thank you to share
Questionwindows task bar issuememberNick Parnham21 Jan '13 - 17:41 
Hi,
 
I am using windows 7 and have the task bar set to auto hide. the task bar does not display in the demo?
 
is this a known issue?
AnswerRe: windows task bar issuemvpadriancs16 May '13 - 2:38 
Hi, it seems that this project has stopped support. Another group of programmers has taken the development of this project. A new version of this Ribbon is released. Please visit the new site for latest fixes, releases, information and downloads.
 
Development site: http://officeribbon.codeplex.com
CodeProject Article: Easily Add a Ribbon into a WinForms Application (C#)[^]
QuestionYour Ribbon in VB .netmemberdatomjim13 Jan '13 - 10:06 
I do UI work not code work. I am wondering if there is a VB version of this that I can implement in a project? It looks fantastic
AnswerSimple Example in VB.NETmvpadriancs13 Jan '13 - 15:53 
Hi, there is a simple example in VB.NET.
here: http://officeribbon.codeplex.com/releases/view/100262[^]
The above link is a continuation project of this ribbon.
Questionpanel below ribbonmemberMember 42495434 Dec '12 - 20:46 
hi!
when i add a new panel below the ribbon to create child form i have a problem.
to maximize child form may double click on her header and resize is doing emmidiatelly.
but, if i click a maxsize button - forms (and all application) is busy ~5sec... Frown | :(
hmm, and if close this child form, it busy...and then closed normally
 
can you help me to patch it?
 
ps
sorry for my english
AnswerRe: panel below ribbonmemberadriancs3 Jan '13 - 2:32 
Hi, it seems that the support of this version ribbon has been stopped. A group of fans of this ribbon has continued to develop/enhance and provide support for it.
Lots of the bugs have been solved in new version.
I have posted an article explaining about the new version of this ribbon at here:
Easily Add a Ribbon into a WinForms Application (C#)[^]
You may want to check it out.
QuestionAmbiguousmemberMember 88411261 Dec '12 - 13:39 
I love your control but keep getting "'Ribbon' is ambiguous in the namespace 'System.Windows.Forms'" any clues would help
AnswerRe: Ambiguousmemberadriancs3 Jan '13 - 2:33 
You may want to have a look on the guide at here:
Easily Add a Ribbon into a WinForms Application (C#)[^]
QuestionImpossible to use with up to date VS 2010 and Framework 4 Winform applicationmembercook3212 Nov '12 - 23:15 
Hi all,
 
I am trying to use this wonderfull control but after adding it on a simple form in a brand new Winform application I am no more able to open the designer of the form :
 
- First problem :
 
Opening the design view of the form gives Exception with no other window open (no code, nothing) : 'System.ComponentModel.Design.ExceptionCollection'
 
- Second problem :
 
If one cs file is open, when I double click on the form, I receive the designer report window :
 
Similar to this picture
 
Most of the time if I click Ignore and continue, some parts of the control disappeared...Thumbs Down | :thumbsdown:
 
Thanks for your help !
Cook32

AnswerRe: Impossible to use with up to date VS 2010 and Framework 4 Winform applicationmemberadriancs3 Jan '13 - 2:28 
Hi, the support of this ribbon might has stopped. A group of fans of this ribbon has continued to develop/enhance and provide support for it.
Lots of the bugs have been solved in new version.
I have posted an article explaining about the new version of this ribbon at here:
Easily Add a Ribbon into a WinForms Application (C#)[^]
You may want to check it out.
QuestionHow To remove or Hide all orb panel.membershyam_s5 Nov '12 - 23:54 
Hi Jose.
 
I appreciate you for your Excellent work.I want to know is it possible to remove or hide the orb panel,show only the ribbon tabs.
QuestionToolTipsmemberWilliam Sade5 Nov '12 - 17:21 
Hi.
 
First of all, I'd like to congratulate for the excelent job.
I am using Ribbon in my application and it works fine.
 
Is there any way to show hints (ToolTips) over the buttons?
I set the property but nothing happened.
 
Thanks.
William
AnswerRe: ToolTipsmemberadriancs3 Jan '13 - 2:48 
Hi, the support of this ribbon might has stopped. A group of fans of this ribbon has continued to develop/enhance and provide support for it.
Lots of the bugs have been solved in new version. These included the tooltip fix too.
I have posted an article explaining about the new version of this ribbon at here:
Easily Add a Ribbon into a WinForms Application (C#)[^]
You may want to check it out.
BugVisual Studio 2010 error when inserting itemsmembermasterkale3 Nov '12 - 17:16 
Hi,
 
When a new item is inserted in a ribbon items list it doesnt refresh the ribbon straight away.
 
Going to a different ribbon and coming back forces it to refresh the ribbon but we have to close it down and reopen it to refresh as when we initially come back it gives an error:
 
RibbonButton.MeasureSize()
RibbonPanel.cs Line 669
 
Any help would be much appreciated!
Thanks
Tristan
GeneralRe: Visual Studio 2010 error when inserting itemsmemberadriancs3 Jan '13 - 2:34 
Hi, the support of this ribbon might has stopped. A group of fans of this ribbon has continued to develop/enhance and provide support for it.
Lots of the bugs have been solved in new version.
I have posted an article explaining about the new version of this ribbon at here:
Easily Add a Ribbon into a WinForms Application (C#)[^]
You may want to check it out.
QuestionThanksmemberVortex.piggy25 Oct '12 - 2:24 
Thanks, help a lot Laugh | :laugh:

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 12 Jun 2012
Article Copyright 2008 by Jose Menendez Póo
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid