IRibbonMainButton.Buttons

Syntax

Buttons: IRibbonElementsCollection;

Description

The Buttons property returns the collection of buttons that should be available in the main menu.

Comments

Three buttons can be created in this collection. Buttons must be located after all main menu items.

NOTE. When adding the buttons from the code their visual layout is organized from the bottom up according to the order of buttons addition because of the implementation features. That is, the button created first is located below, the button created second is located under the first, and so on.

Example

Executing the example requires a form with the button named Button1 on it, the Ribbon component named Ribbon1 and the ImageList component named ImageList1. Two images are loaded to ImageList1: the first one for the Hlp command, the second one is for the Exit command.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    MainCategory: IRibbonCategory;
    MainButton: IRibbonMainButton;
    SubItems, Buttons: IRibbonElementsCollection;
    Element: IRibbonButton;
Begin
    //Base parameters of the main menu
    MainCategory := Ribbon1.MainCategory;
    MainCategory.SmallImages := ImageList1;
    MainCategory.Keys := "F";
    //Menu contents setup
    MainButton := Ribbon1.MainButton;
    SubItems := MainButton.SubItems;
    Buttons := MainButton.Buttons;
    SubItems.Clear;
    Buttons.Clear;
    //Elements
    //First item
    Element := New RibbonMainCategoryButton.Create;
    SubItems.Add(Element);
    Element.Text := "Open";
    //The second item
    Element := New RibbonMainCategoryButton.Create;
    SubItems.Add(Element);
    Element.Text := "Save";
    //The third item
    Element := New RibbonMainCategoryButton.Create;
    SubItems.Add(Element);
    Element.Text := "Save as";
    //Buttons
    //Exit button
    Element := New RibbonMainCategoryButton.Create;
    Buttons.Add(Element);
    Element.Text := "Quit";
    Element.ImageIndex := 1;
    //Parameters button
    Element := New RibbonMainCategoryButton.Create;
    Buttons.Add(Element);
    Element.Text := "Parameters";
    //Help button
    Element := New RibbonMainCategoryButton.Create;
    Buttons.Add(Element);
    Element.Text := "Help";
    Element.ImageIndex := 0;
    Element.ImageIndex := 0;
    //Application button style
    MainButton.ColorStyle := RibbonMainButtonColorStyle.Red;
    MainButton.Text := "File";
End Sub Button1OnClick;

Main ribbon menu is formed by clicking the button. The menu looks approximately as follows:

See also:

IRibbonMainButton