ComponentOne Ribbon for WinForms
C1Ribbon (Classic) Elements / Ribbon Item Group
In This Topic
    Ribbon Item Group
    In This Topic

    Each Ribbon tab contains a set of Ribbon groups. Grouping related commands in a RibbonGroup makes it easier to discover and locate the commands. The TrimLongCaption property allows the RibbonGroup caption to be trimmed if it is longer than the contents of the group. The group can also include a dialog box launcher button which provides access to advanced capabilities.

    The following image shows the Home tab with four groups: Clipboard, Font, Paragraph, and Styles:
    Ribbon groups


    The RibbonGroup can contain a number of Ribbon items, such as buttons, check boxes, combo boxes, toolbars, menus, and so on. For example, the following Font group organizes related font commands and contains numerous Ribbon items:
    Ribbon group

    Collapsing Group

    Note that when more Ribbon groups are added, the existing Ribbon groups may have to resize to make room on the tab for the new group(s). If resizing is necessary, the large icons in the group are automatically replaced with small icons and text is hidden if space does not allow for the text. If there is not enough room on the tab to display all of the group's items at one time, then the group collapses.
    Collapsing group


    Items Available to Add to the Group

    With the design-time support, you can easily add Ribbon items to the RibbonGroup. To see a list of available Ribbon items, click the Actions button located on the group floating toolbar and choose from the following list:


    Add ribbon items

    For steps on adding items to the Ribbon group, see the Adding Items to the Ribbon Group topic.

    Dialog Launcher Button

    Included in the functional group of the Ribbon, the dialog launcher connects the simple functionality of the Ribbon and the advanced functionality of the dialog box. A group can contain only a single dialog launcher button.

    The following image shows the Font group's dialog launcher button:dialog launcher button in ribbon

    To implement the dialog launcher button:

    1. Select the group by clicking it.
    2. In the Properties window, click the Events button.
    3. Double-click the empty area to the right of the DialogLauncherClick event. An empty event handler will be added.
    4. Enter the event handling code so that the entire event handler looks like this:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      ' type the Imports directive for the namespace
      Imports C1.Win.C1Ribbon
       
      Private Sub FontGroup_DialogLauncherClick (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontGroup.DialogLauncherClick
          Dim dlg As FontDialog = New FontDialog
          Dim font As Font = Me.RichTextBox1.SelectionFont
            If Not (font Is Nothing) Then
             dlg.Font = font 
           End If 
           If (dlg.ShowDialog = System.Windows.Forms.DialogResult.OK) Then
               Me.RichTextBox1.SelectionFont = dlg.Font
           End If
      End Sub
      

      To write code in C#

      C#
      Copy Code
      // type the using directive for the namespace
      using C1.Win.C1Ribbon;
       
      private void FontGroup_DialogLauncherClick (object sender, EventArgs e)
      {
          FontDialog dlg = new FontDialog ();
          Font font = this.richTextBox1.SelectionFont;
          if (font != null) dlg.Font = font;
          if (dlg.ShowDialog () != System.Windows.Forms.DialogResult.OK) return;
          this.richTextBox1.SelectionFont = dlg.Font;
      }
      

    Note that for the above code the RibbonGroup.Name property has been set to FontGroup.