Color of text

May 23, 2012 at 9:10 PM

Hello,

Is it possible to change the text color of a button in the ribbon?

If so, what changes should we make in the source code?

Thank you in advance.

Yours

Developer
May 25, 2012 at 2:00 PM

you can here:

http://ribbon.codeplex.com/wikipage?title=How%20to%20Make%20a%20New%20Theme%2c%20Skin%20for%20this%20Ribbon%20Programmatically&referringTitle=Documentation

May 25, 2012 at 7:35 PM

Hello,

Thank you for your response. I had not seen that it is possible to customize the ribbon in this way.

Yours.

May 25, 2012 at 9:01 PM

Hello,

I have not been specific enough in my application. What I want to do is something like:

if condition then
    button color = red
else
    button color = green
end if

I do not want to change the whole color of all elements.

In fact, I wonder if someone wrote a property textcolor for buttons?

I do not control enough c # to do so.

Thank you in advance.

Yours.

Developer
May 26, 2012 at 2:48 PM
Edited May 26, 2012 at 3:39 PM

yes, You can change the color at any time. You just need to define the color of that button.

First, create a few class to define the color.

Follow this guide [How to Make a New Theme, Skin for this Ribbon Programmatically] to create the class. If you just want to change the button's color, you can do something like this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace System.Windows.Forms
{
    public class RibbonRed : RibbonProfesionalRendererColorTable
    {
        public RibbonRed()
        {
            ButtonSelectedBgOut = Color.Red;
            ButtonSelectedBgCenter = Color.Red;
            ButtonSelectedBorderOut = Color.Red;
            ButtonSelectedBorderIn = Color.Red;
            ButtonSelectedGlossyNorth = Color.Red;
            ButtonSelectedGlossySouth = Color.Red;
        }
    }

    public class RibbonGreen : RibbonProfesionalRendererColorTable
    {
        public RibbonGreen()
        {
            ButtonSelectedBgOut = Color.Green;
            ButtonSelectedBgCenter = Color.Green;
            ButtonSelectedBorderOut = Color.Green;
            ButtonSelectedBorderIn = Color.Green;
            ButtonSelectedGlossyNorth = Color.Green;
            ButtonSelectedGlossySouth = Color.Green;
        }
    }

    public class RibbonYellow : RibbonProfesionalRendererColorTable
    {
        public RibbonYellow()
        {
            ButtonSelectedBgOut = Color.Yellow;
            ButtonSelectedBgCenter = Color.Yellow;
            ButtonSelectedBorderOut = Color.Yellow;
            ButtonSelectedBorderIn = Color.Yellow;
            ButtonSelectedGlossyNorth = Color.Yellow;
            ButtonSelectedGlossySouth = Color.Yellow;
        }
    }
}

Then, at your main form, your codes might look like this:

private void ChangeRibbonButtonColor(string newcolor)
{
    if (newcolor == "Red")
    {
        (ribbon1.Renderer as RibbonProfessionalRenderer).ColorTable =
            new RibbonRed();
        this.Refresh();
    }
    else if (newcolor == "Green")
    {
        (ribbon1.Renderer as RibbonProfessionalRenderer).ColorTable =
            new RibbonGreen();
        this.Refresh();
    }
    else if (newcolor == "Yellow")
    {
        (ribbon1.Renderer as RibbonProfessionalRenderer).ColorTable =
            new RibbonYellow();
        this.Refresh();
    }
}
In the above will change 6 elements' color in Ribbon Control. There are many more elements available for you to modify.
Developer
May 16, 2013 at 1:29 PM
Hi, a new version of Ribbon is released. Please visit the new site for latest fixes, releases, information and downloads.
New site: http://officeribbon.codeplex.com/