Ribbon for WinForms
テーマ
リボンの使用 > テーマ

A user can apply themes to the C1Ribbon control in the WinForms application by selecting one of the built-in themes, which can be accessed by adding the reference assembly C1.Win.C1Themes.4.5.2.

themes in ribbon

The assembly provides the following built-in themes:

In this section we have covered an example of adding the Themes functionality to C1Ribbon through code. We have used a ComboBox control to populate the available themes. You can use any preferred control to populate the Themes. Refer the code snippet below.

Public Class ComboBoxHost
    Inherits RibbonControlHost
    Public Sub New()
        MyBase.New(New System.Windows.Forms.ComboBox())
        Dim ribbonBox = DirectCast(MyBase.Control, ComboBox)
        ribbonBox.Items.AddRange(C1ThemeController.GetThemes())
        ribbonBox.Text = "Select a theme"
        AddHandler ribbonBox.SelectedIndexChanged, AddressOf RibbonBox_SelectedIndexChanged
    End Sub

    Private Sub RibbonBox_SelectedIndexChanged(sender As Object, e As EventArgs)
        Dim themmeCombo As ComboBox = DirectCast(sender, ComboBox)
        Dim theme As C1Theme = C1ThemeController.GetThemeByName(themmeCombo.Text, False)
        C1ThemeController.ApplyThemeToControlTree(Me.Ribbon, theme)
    End Sub
End Class
    private void c1Ribbon1_RibbonEvent(object sender, RibbonEventArgs e)
    {
        //利用可能なテーマをコンボボックスに適用します
        var themeCombo = (ComboBox)comboBoxHost1.Control;
        themeCombo.Items.AddRange(C1ThemeController.GetThemes());
        themeCombo.Text = "Select a theme";
        themeCombo.SelectedIndexChanged += ThemeCombo_SelectedIndexChanged;
    }

    //選択したテーマをリボンに適用します
    private void ThemeCombo_SelectedIndexChanged(object sender, EventArgs e)
    {
        ComboBox themmeCombo = ((ComboBox)sender);
        C1Theme theme = C1ThemeController.GetThemeByName(themmeCombo.Text, false);
        C1ThemeController.ApplyThemeToControlTree(this.Ribbon, theme);
    }
}

//ControlHostのRibbonGroupアイテムを使用してComboBoxをリボンに追加します
public class ComboBoxHost : RibbonControlHost
{
    public ComboBoxHost() : base(new System.Windows.Forms.ComboBox())
    {

    }
}