Click here to Skip to main content
13,357,610 members (58,366 online)
Click here to Skip to main content
Add your own
alternative version


490 bookmarked
Posted 14 May 2007

Improved and Recoded RibbonMenuButton

, 5 Jun 2007
Rate this:
Please Sign up or sign in to vote.
A new version with many functionalities
Screenshot - presentation.png


First of all, thanks to everyone. I am grateful to know that people value this effort. I remember like yesterday when I was sixteen, more or less, and I saw many types of software, apps and games. For me, it was impossible to access and develop software then. I have learned a lot since, however, and I realize that it's now one million times easier to access this kind of software. Furthermore, if I can help anyone to create eye-candy apps, I've decided that they can use my code freely.


I was thinking about how to make a fully customizable button and about how difficult it was changing RGB components. I decided to make RibbonColor, which has many options to operate with colors. If you play the demo app, you will understand quickly as you move the Hue, Sat and Brightness track bar. I have to admit that I have approximately 70% of the new RibbonControl library finished. However, as people are anxious to have improved code and have told me that I did not explain practically anything about my code, I've decided to do this like for dummies. So, here we go.

How to Use the Code

First of all, create a new Windows application. From the Solution Explorer, choose the option Add Existing Item. Then choose RibbonMenuButton.cs and Rebuild the project. Now, if you go to the form1 designer, in the toolbox you will have RibbonMenuButton. Drag it to the form. You will see a control without sense, but let's play with the properties. First, set properties for the RibbonMenuButton:

Screenshot - ribbonmenubuttonprops.png

When you have set the properties, add an image, set the text you want and set the font to Segoe UI if you have it. You will have something like this:

Screenshot - trialbutton.png

If you have compiled the project and you get this, the next step is to change the properties of the control. Let's see what each property represents. I recommend that you look at the button's Properties settings in the demo project:

  • Arrow: Paints an arrow ToRight or ToDown; this only paints, as the double functionality is in another property.
  • Colors: I think this doesn't need explanation; I recommend you to use the PlayGround app to choose your colors.
  • FadingSpeed: This facilitates fading between colors; choose 0 to avoid fading.
  • GroupPos: This is to make round corners on the Left, Right, Center (None), Top or Bottom.
  • ImageLocation: To put the image on the Left, Right, Top or Bottom.
  • ImageOffset: To offset from the borders.
  • MaxImageSize: To make buttons larger with a scaling image limit.
  • Radius: The corner radius.
  • ShowBase: If you want to show the BaseColor and BaseStroke color where Transparent is a color and makes fading. If set to No, it doesn't make fading.
  • SplitButton: Creates a double function button; the arrow section opens the associated ContextMenu and the other section, the main event.
  • SplitDistance: How big the arrow section button is.
  • Title: If you set this different from "", it automatically puts the title bold and under the text.
  • Text: If you have a title and want two lines of text, add \n to the text to make two lines.
  • KeepPress, IsPressed: If KeepPress is active on some buttons, when one of them is pressed, it keeps the press and the others in the containers lose the IsPress.

I have tried to crash the app, but it always works. So, I think the code is effectively error-free.

Points of Interest

If you want to learn more about these controls, I recommend that you take a look at:

  • this.Region: That's a good way to avoid matters of transparency.
  • LinearGradient With multiple colors, that makes the gradients easy.
  • MeasureString: That's a good method to position the text because you have to take away the base.OnPaint -> you have to do everything, including write the text.
  • TransformColors Method including the alpha opacity.
  • DrawArc method: As you can see, with the radius you can make smooth corners.
  • OnMouseUp: Here you can see what happens when the SplitButton is activated and IsPressed activated.
  • RibbonColor: I took the formulas from Wikipedia and Gimp. The System.Drawing.Color.GetHue, Sat and Brightness don't work well.


  • 5 June, 2007. 1.6 - Solved Repaint, ChangingSize and excessive CPU consumption. Added KeepPress and IsPress functionality.
  • 16 May, 2007. 1.5 - Because I had to recode everything when I learned how to use Hue, Saturation and Brightness.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


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:

Take a look to my blog

You may also be interested in...

Comments and Discussions

GeneralFound a bug on right clicking a button... [modified] Pin
Octopod10-Jan-08 6:50
memberOctopod10-Jan-08 6:50 
Generalso cool Pin
JackChen19877-Jan-08 23:11
memberJackChen19877-Jan-08 23:11 
GeneralI'm confused Pin
tcsoccerman4-Dec-07 14:49
membertcsoccerman4-Dec-07 14:49 
GeneralAnother CPU bug Pin
Jordiproatec29-Nov-07 3:30
memberJordiproatec29-Nov-07 3:30 
General3 bug fixes (includin CPU issues) Pin
gpgemini13-Oct-07 12:01
membergpgemini13-Oct-07 12:01 
GeneralTextAlign requests are ignored Pin
GrantM2-Oct-07 11:19
memberGrantM2-Oct-07 11:19 
QuestionHow to unable a RibbonMenuButton? Pin
ivanchain@hotmail.com16-Sep-07 15:43
memberivanchain@hotmail.com16-Sep-07 15:43 
GeneralHi, about the icons Pin
ivanchain@hotmail.com11-Sep-07 4:44
memberivanchain@hotmail.com11-Sep-07 4:44 
GeneralRe: Hi, about the icons Pin
Alpha Nerd24-May-08 8:32
memberAlpha Nerd24-May-08 8:32 
GeneralUsing this button as toolstripbutton Pin
Vincent_ws10-Sep-07 18:09
memberVincent_ws10-Sep-07 18:09 
Generalmissing Ribbon Menu Pin
Kamalmostofi31-Aug-07 12:40
memberKamalmostofi31-Aug-07 12:40 
AnswerRe: missing Ribbon Menu Pin
qien15-Oct-07 23:32
memberqien15-Oct-07 23:32 
QuestionImage clipping Pin
joncle12312-Aug-07 8:50
memberjoncle12312-Aug-07 8:50 
GeneralCPU problems Pin
Roey C4-Aug-07 12:05
memberRoey C4-Aug-07 12:05 
GeneralRe: CPU problems Pin
Roey C4-Aug-07 12:07
memberRoey C4-Aug-07 12:07 
QuestionIsPressed = true paint bug [modified] Pin
alleph26-Jul-07 10:51
memberalleph26-Jul-07 10:51 
QuestionBug? Pin
jdem26-Jul-07 6:33
memberjdem26-Jul-07 6:33 
Generalabout Office 2007 UI Licence Pin
alleph24-Jul-07 22:43
memberalleph24-Jul-07 22:43 
AnswerRe: about Office 2007 UI Licence Pin
Praded5-Aug-07 4:26
memberPraded5-Aug-07 4:26 
Generalmistake ,deadliness Pin
qingtianyu911-Jul-07 20:43
memberqingtianyu911-Jul-07 20:43 
Generalthe code.. Pin
Seishin#19-Jun-07 6:00
memberSeishin#19-Jun-07 6:00 
GeneralRe: the code.. [modified] Pin
Mario M.16-Sep-07 6:15
memberMario M.16-Sep-07 6:15 
GeneralIcons Pin
shawn3219-Jun-07 3:31
membershawn3219-Jun-07 3:31 
GeneralRe: Icons Pin
Juan Pablo G.C.19-Jun-07 5:20
memberJuan Pablo G.C.19-Jun-07 5:20 
GeneralCustomer Border Form Pin
cdemez11-Jun-07 22:34
membercdemez11-Jun-07 22:34 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 5 Jun 2007
Article Copyright 2007 by Juan Pablo G.C.
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid