This topic showcases the implementation of a simple themes application which includes a C1Ribbon and ComboBox with a list of all the inbuilt themes.
To create a simple WinForms application in .NET for Themes control, complete the following steps:
Initialize the C1Themes object.
Initialize the C1Themes class.
Add the following code to the form load event:
Add a combobox with name cmb_list and button with name btn_apply.
Add the following code to the SelectedIndexChanged event of the ComboBox.
The GetThemeByName method in C1ThemeController class retrieves a theme registered with the application, while the ApplyThemeToControlTree method recursively applies a theme to a control.
Run the code and observe the output.
Also, you can directly apply the specific theme using the following code:
C# |
Copy Code
|
---|---|
var theme = C1ThemeController.GetThemeByName("Office2016Green", false); // Apply theme to all controls on the form C1ThemeController.ApplyThemeToControlTree(this, theme); |
Note that in the above code, in place of C1Ribbon, you can use a control name specific to your requirement.
You can also check the product sample specific to the Ribbon implementation with the Themes control, at Documents\ComponentOne Samples\WinForms\C1Themes\C1RibbonBasedApp.