ComponentOne Ribbon for WinForms
Adding Items to the Ribbon Group
C1Ribbon (Classic) Task-Based Help > Adding Ribbon Items > Adding Items to the Ribbon Group

To add items to the Ribbon group, you can use the smart designer, collection editor, or add code. Each option is described below.

To Add Ribbon Items Using the Smart Designer

Complete the following steps:

  1. Select the Ribbon group to enable the group's floating toolbar:
  2. Click the Actions drop-down button. This reveals a list of Ribbon items to add to the group.
  3. Select an item to add, Add ToggleButton, for example.
  4. To delete the toggle button's label, click the text so that it is highlighted and press DELETE.
  5. Press ENTER or click outside the editing box to accept the change.
  6. To add an image, click the toggle button to activate it and enable the toggle button's floating toolbar:
  7. Click the Change Image button . The Change Image dialog box appears.
  8. Click the Small Image (16x16) drop-down arrow and select the AlignTextLeft image.
  9. Continue to build on the group by adding Ribbon elements, such as buttons, check boxes, combo boxes, toolbars, and so on to fit your needs.

To Add Ribbon Items Using the Collection Editor

Complete the following steps:

  1. Select the group that you want to add Ribbon items to. This activates the group.
  2. From the Ribbon group's Properties window, select the Items property and click the ellipsis button at the right side of the (Collection).

    The RibbonGroup Items Collection Editor appears.
  3. From the collection editor, click the Add drop-down button.
  4. Select RibbonToggleButton from the list of available items. The new item is listed in the Members list.

    With the new item is highlighted, you can edit the properties through the Properties list.
  5. Click OK to close the collection editor.

To Add Ribbon Items Programmatically

Note: In the following example embedded resources containing the following (16x16) images are used: AlignLeft.png, AlignCenter.png, and AlignRight.png. To embed a resource, from the Project menu, choose YourProjectName Properties. From the Resources tab, select Add Resource and choose to add use an existing file or add a new one.

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";
}