To add items to the Ribbon group, you can use the smart designer, collection editor, or add code. Each option is described below.
Complete the following steps:
Complete the following steps:
To add Ribbon items to the group, for example, a toggle buttons, add the following code to your project:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
' type the Imports directive for the namespace Imports C1.Win.C1Ribbon Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Add a tab Dim RibbonTab2 As New RibbonTab() ' Label the tab RibbonTab2.Text = "Write" c1Ribbon1.Tabs.Add(RibbonTab2) ' Add a group to the Write tab Dim RibbonGroup2 As New RibbonGroup() ' Label the group RibbonGroup2.Text = "Font" RibbonTab2.Groups.Add(RibbonGroup2) Dim ToggleBtn1 As New RibbonToggleButton() ' Add RibbonToggleButton to the Ribbon Group RibbonGroup2.Items.Add(ToggleBtn1) ' Edit the toggle button properties ToggleBtn1.SmallImage = My.Resources.Resources.AlignLeft ToggleBtn1.Text = "" ToggleBtn1.ToolTip = "Align Left" End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
// type the using directive for the namespace using C1.Win.C1Ribbon; private void Form1_Load(object sender, System.EventArgs e) { // Add a tab RibbonTab RibbonTab2 = new RibbonTab(); // Label the tab RibbonTab2.Text = "Write"; C1Ribbon1.Tabs.Add(RibbonTab2); // Add a group to the Write tab RibbonGroup RibbonGroup2 = new RibbonGroup(); // Label the group RibbonGroup2.Text = "Font"; RibbonTab2.Groups.Add(RibbonGroup2); RibbonToggleButton ToggleBtn1 = new RibbonToggleButton(); // Add RibbonToggleButton to the Ribbon Group RibbonGroup2.Items.Add(ToggleBtn1); // Edit the toggle button properties ToggleBtn1.SmallImage = Properties.Resources.AlignLeft; ToggleBtn1.Text = ""; ToggleBtn1.ToolTip = "Align Left"; } |