How to apply office color scheme to any control in WinForms?
Color schemes
The color scheme is applied in the Office2007Form and Office2010Form, by default and the color scheme cannot be applied to controls placed in the Form. So, it is required to specify the colors for the controls placed in the Form based on the color scheme. The color scheme of the Office2007Form can be applied by using the property, ColorScheme.
There are four different color schemes available in the WinForms Office2007 Form.
- Blue
- Black
- Silver
- Managed
Managed color scheme helps to apply the user-defined colors. The Managed color scheme can be applied to the Office2007Form by using the function, ApplyManagedColors. Each and every item of the colors in the Office2007Form can be acquired by using the function, GetColorTable in the Office2007Colors.
C#
//Sets the color scheme as blue this.ColorScheme = Office2007Theme.Blue; //Changes the Back color of the GradientPanel to Office2007Blue this.gradientPanel1.BackColor = Color.FromArgb(187, 212, 246); //Sets the color scheme as black this.ColorScheme = Office2007Theme.Black; //Changes the Back color of the GradientPanel to Office2007Black this.gradientPanel1.BackColor = Color.FromArgb(113, 113, 113); //Sets the color scheme as silver this.ColorScheme = Office2007Theme.Silver; //Changes the Back color of the GradientPanel to Office2007Silver this.gradientPanel1.BackColor = Color.FromArgb(202, 207, 217); //Sets the managed color scheme for Office2007Form this.ColorScheme = Office2007Theme.Managed; //Applies the managed color to Office2007Form Office2007Colors.ApplyManagedColors(this, Color.Red); //Gets the form back color from the color table Color color = Office2007Colors.GetColorTable(Office2007Theme.Managed).FormBackground; //Changes the Back color of the GradientPanel to Managed color this.gradientPanel1.BackColor = color;
VB
'Sets the color scheme as black Me.ColorScheme = Office2007Theme.Black 'Changes the Back color of the GradientPanel to Office2007Black Me.gradientPanel1.BackColor = Color.FromArgb(113, 113, 113) 'Sets the color scheme as blue Me.ColorScheme = Office2007Theme.Blue 'Changes the Back color of the GradientPanel to Office2007Blue Me.gradientPanel1.BackColor = Color.FromArgb(187, 212, 246) 'Sets the color scheme as silver Me.ColorScheme = Office2007Theme.Silver 'Changes the Back color of the GradientPanel to Office2007Silver Me.gradientPanel1.BackColor = Color.FromArgb(202, 207, 217) 'Sets the managed color scheme for Office2007Form Me.ColorScheme = Office2007Theme.Managed 'Applies the managed color to Office2007Form Office2007Colors.ApplyManagedColors(Me, System.Drawing.Color.Red) 'Gets the form back color from the color table Dim color As Color = Office2007Colors.GetColorTable(Office2007Theme.Managed).FormBackground 'Changes the Back color of the GradientPanel to Managed color Me.gradientPanel1.BackColor = color
Figure 1: ColorScheme is set as Blue
Figure 2: ColorScheme is set as Black
Figure 3: ColorScheme is set as Silver
Figure 4: ColorScheme is set as Managed
Samples:
C#:https://www.syncfusion.com/downloads/support/forum/119261/ze/Office2007Form1557056153
VB:https://www.syncfusion.com/downloads/support/forum/119261/ze/Office2007Form_VB1447920667
Reference link: https://help.syncfusion.com/windowsforms/office2007form/color-schemes
Conclusion
I hope you enjoyed learning about how to apply office color scheme to control in WinForms.
You can refer to our WinForms Office2007 Form feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!