How to change default ButtonX and ButtonItem colors, DotNetBar for WinForms
Categories: DotNetBar for Windows Forms, How To
Use following code from your main form Load event, note that if style is changed using StyleManager these changes must be applied again.
C#:
using DevComponents.DotNetBar.Rendering; using DevComponents.DotNetBar; private void Form1_Load(object sender, EventArgs e) { // Change mouse over colors for the default ButtonItem color table and the ButtonX color table Office2007ColorTable table = ((Office2007Renderer)GlobalManager.Renderer).ColorTable; // Default ButtonItem Color Office2007ButtonItemColorTable bt = table.ButtonItemColors[0]; bt.MouseOver.TopBackground = new LinearGradientColorTable(Color.Red); bt.MouseOver.BottomBackground = new LinearGradientColorTable(Color.Yellow); bt.MouseOver.OuterBorder = new LinearGradientColorTable(Color.Green); bt.MouseOver.InnerBorder = new LinearGradientColorTable(Color.Gold); // Change default ButtonX color bt = table.ButtonItemColors[Enum.GetName(typeof(eButtonColor), eButtonColor.OrangeWithBackground)]; bt.MouseOver.TopBackground = new LinearGradientColorTable(Color.Green); bt.MouseOver.BottomBackground = new LinearGradientColorTable(Color.Gold); bt.MouseOver.OuterBorder = new LinearGradientColorTable(Color.BlueViolet); bt.MouseOver.InnerBorder = new LinearGradientColorTable(Color.BurlyWood); bt.MouseOver.Text = Color.Red; }
VB:
Imports DevComponents.DotNetBar.Rendering Imports DevComponents.DotNetBar Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) ' Change mouse over colors for the default ButtonItem color table and the ButtonX color table Dim table As Office2007ColorTable = CType(GlobalManager.Renderer, Office2007Renderer).ColorTable ' Default ButtonItem Color Dim bt As Office2007ButtonItemColorTable = table.ButtonItemColors(0) bt.MouseOver.TopBackground = New LinearGradientColorTable(Color.Red) bt.MouseOver.BottomBackground = New LinearGradientColorTable(Color.Yellow) bt.MouseOver.OuterBorder = New LinearGradientColorTable(Color.Green) bt.MouseOver.InnerBorder = New LinearGradientColorTable(Color.Gold) ' Change default ButtonX color bt = table.ButtonItemColors(System.Enum.GetName(GetType(eButtonColor), eButtonColor.OrangeWithBackground)) bt.MouseOver.TopBackground = New LinearGradientColorTable(Color.Green) bt.MouseOver.BottomBackground = New LinearGradientColorTable(Color.Gold) bt.MouseOver.OuterBorder = New LinearGradientColorTable(Color.BlueViolet) bt.MouseOver.InnerBorder = New LinearGradientColorTable(Color.BurlyWood) bt.MouseOver.Text = Color.Red End Sub
Related posts:
- How to create custom colors for RibbonTabItem and RibbonTabItemGroup objects
- How to set custom shape for ButtonX or ButtonItem
- How to change the ButtonItem.Symbol property using code
- How to change TabControl tab and panel colors
- How to Customize DateTimeInput, DoubleInput, IntegerInput and TextBoxX colors
Leave a Reply!