To create new custom color tables for ribbon tabs and ribbon tab groups you need to set CustomColorName property on RibbonTabItem and RibbonTabItemGroup objects with the name of the custom color table you created and have added to Office2007ColorTable.

Here is sample code that creates new color tables for ribbon tab and ribbon tab group. Usually you would have this code in form load event or running in constructor… You need to execute it only once or after the color table has changed.

CS:

Office2007RibbonTabGroupColorTable tg = new Office2007RibbonTabGroupColorTable();
tg.Background = new LinearGradientColorTable(Color.Yellow, Color.Green);
tg.BackgroundHighlight = new LinearGradientColorTable();
tg.Border = new LinearGradientColorTable(Color.Gold);
tg.Name = "MyGroupColorTable";
Office2007ColorTable ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
ct.RibbonTabGroupColors.Add(tg);
 
Office2007RibbonTabItemColorTable tc = new Office2007RibbonTabItemColorTable();
tc.Name = "MyColor1";
tc.Default = new Office2007RibbonTabItemStateColorTable();
tc.Default.Background = new LinearGradientColorTable();
tc.Default.BackgroundHighlight = new LinearGradientColorTable();
tc.Default.InnerBorder = new LinearGradientColorTable();
tc.Default.OuterBorder = new LinearGradientColorTable();
tc.Default.Text = Color.Black;
 
tc.MouseOver = new Office2007RibbonTabItemStateColorTable();
tc.MouseOver.Background = new LinearGradientColorTable(Color.Beige, Color.Azure);
tc.MouseOver.BackgroundHighlight = new LinearGradientColorTable();
tc.MouseOver.InnerBorder = new LinearGradientColorTable(Color.Bisque);
tc.MouseOver.OuterBorder = new LinearGradientColorTable(Color.BlueViolet);
tc.MouseOver.Text = Color.Black;
tc.Selected = new Office2007RibbonTabItemStateColorTable();
tc.Selected.Background = new LinearGradientColorTable(Color.BurlyWood, Color.Chartreuse);
tc.Selected.BackgroundHighlight = new LinearGradientColorTable();
tc.Selected.InnerBorder = new LinearGradientColorTable(Color.Bisque);
tc.Selected.OuterBorder = new LinearGradientColorTable(Color.BlueViolet);
tc.Selected.Text = Color.Black;
 
tc.SelectedMouseOver = new Office2007RibbonTabItemStateColorTable();
tc.SelectedMouseOver.Background = new LinearGradientColorTable(Color.BurlyWood, Color.Chartreuse);
tc.SelectedMouseOver.BackgroundHighlight = new LinearGradientColorTable();
tc.SelectedMouseOver.InnerBorder = new LinearGradientColorTable(Color.BlueViolet);
tc.SelectedMouseOver.OuterBorder = new LinearGradientColorTable(Color.CadetBlue);
tc.SelectedMouseOver.Text = Color.Black;
 
ct.RibbonTabItemColors.Add(tc);

VB:

Dim tg As New Office2007RibbonTabGroupColorTable()
tg.Background = New LinearGradientColorTable(Color.Yellow, Color.Green)
tg.BackgroundHighlight = New LinearGradientColorTable()
tg.Border = New LinearGradientColorTable(Color.Gold)
tg.Name = "MyGroupColorTable"
Dim ct As Office2007ColorTable = (CType(GlobalManager.Renderer, Office2007Renderer)).ColorTable
ct.RibbonTabGroupColors.Add(tg)
 
Dim tc As New Office2007RibbonTabItemColorTable()
tc.Name = "MyColor1"
tc.Default = New Office2007RibbonTabItemStateColorTable()
tc.Default.Background = New LinearGradientColorTable()
tc.Default.BackgroundHighlight = New LinearGradientColorTable()
tc.Default.InnerBorder = New LinearGradientColorTable()
tc.Default.OuterBorder = New LinearGradientColorTable()
tc.Default.Text = Color.Black
 
tc.MouseOver = New Office2007RibbonTabItemStateColorTable()
tc.MouseOver.Background = New LinearGradientColorTable(Color.Beige, Color.Azure)
tc.MouseOver.BackgroundHighlight = New LinearGradientColorTable()
tc.MouseOver.InnerBorder = New LinearGradientColorTable(Color.Bisque)
tc.MouseOver.OuterBorder = New LinearGradientColorTable(Color.BlueViolet)
tc.MouseOver.Text = Color.Black
tc.Selected = New Office2007RibbonTabItemStateColorTable()
tc.Selected.Background = New LinearGradientColorTable(Color.BurlyWood, Color.Chartreuse)
tc.Selected.BackgroundHighlight = New LinearGradientColorTable()
tc.Selected.InnerBorder = New LinearGradientColorTable(Color.Bisque)
tc.Selected.OuterBorder = New LinearGradientColorTable(Color.BlueViolet)
tc.Selected.Text = Color.Black
 
tc.SelectedMouseOver = New Office2007RibbonTabItemStateColorTable()
tc.SelectedMouseOver.Background = New LinearGradientColorTable(Color.BurlyWood, Color.Chartreuse)
tc.SelectedMouseOver.BackgroundHighlight = New LinearGradientColorTable()
tc.SelectedMouseOver.InnerBorder = New LinearGradientColorTable(Color.BlueViolet)
tc.SelectedMouseOver.OuterBorder = New LinearGradientColorTable(Color.CadetBlue)
tc.SelectedMouseOver.Text = Color.Black
 
ct.RibbonTabItemColors.Add(tc)

Code above assumes that following values are assigned to the instances of RibbonTabItem and RibbonTabItemGroup that you already have on the form: RibbonTabItem.CustomColorName=”MyColor1″ and RibbonTabItemGroup.CustomColorName=”MyGroupColorTable”

Note that you can choose any name you want since string specified is just used as key to find right color table.

Related posts:

  1. How to change default ButtonX and ButtonItem colors, DotNetBar for WinForms
  2. How to customize ColorPickerButton and ColorPickerDropDown colors
  3. How to create custom columns when binding data to AdvTree
  4. How to Customize DateTimeInput, DoubleInput, IntegerInput and TextBoxX colors
  5. How to change TabControl tab and panel colors