Ribbon for WinForms | ComponentOne
Elements / Ribbon Items / ToolBar
In This Topic
    ToolBar
    In This Topic

    A toolbar comprises of a row of clickable items that can perform different tasks. The Ribbon ToolBar provides easy access to the most frequently-used functions. Note that the RibbonToolBar by default contains a button.

    The image below shows a ToolBar with Bold, Italics and Underline buttons in the ribbon application.

    Toolbar

    Adding ToolBar at Design-Time

    The Ribbon ToolBar can be added at design-time using the Ribbon Group Floating Toolbar or RibbonGroup Items Collection Editor. Also, you can customize the look of the Ribbon ToolBar using the Ribbon ToolBar Floating ToolBar or by editing the properties in the Properties Window. For more information about floating toolbars, refer this topic. The user can add items to the Ribbon ToolBar using the RibbonToolBar Items Collection Editor. Refer this topic to know more about Collection Editors.

    The image below depicts the floating toolbar of Ribbon ToolBar

    Floating toolbar

    Adding ToolBar via Code

    A toolbar can also be added programmatically to the Ribbon control using the RibbonToolBar class. This is depicted in the code below:

    ' Add Ribbon Toolbar
    Dim ribbonToolBar As RibbonToolBar = New RibbonToolBar()
    Dim boldButton As RibbonButton = New RibbonButton(Image.FromFile("images\bold.png"))
    Dim italicButton As RibbonButton = New RibbonButton(Image.FromFile("images\italic.png"))
    Dim underlineButton As RibbonButton = New RibbonButton(Image.FromFile("images\underline.png"))
    ribbonToolBar.Items.Add(boldButton)
    ribbonToolBar.Items.Add(italicButton)
    ribbonToolBar.Items.Add(underlineButton)
    formatGroup.Items.Add(ribbonToolBar)
    
    // Add Ribbon Toolbar
    RibbonToolBar ribbonToolBar = new RibbonToolBar();
    RibbonButton boldButton = new RibbonButton(Image.FromFile(@"images\bold.png"));
    RibbonButton italicButton = new RibbonButton(Image.FromFile(@"images\italic.png"));
    RibbonButton underlineButton = new RibbonButton(Image.FromFile(@"images\underline.png"));
    ribbonToolBar.Items.Add(boldButton);
    ribbonToolBar.Items.Add(italicButton);
    ribbonToolBar.Items.Add(underlineButton);
    formatGroup.Items.Add(ribbonToolBar);