IRibbonButton.Action

Syntax

Action: IActionItem;

Description

The Action property determines an action that is associated with the ribbon button.

Comments

Determine one of the actions that is created in the ActionList component collection. On setting the action, values of all properties that are set for the button will be ignored. Values of the corresponding properties of the selected action will be applied instead of them.

Example

Executing the example requires a form, a button named Button1 on the form, the Ribbon component named Ribbon1, and the ActionList component that includes a created action named ActionItem1. A tab and a panel are created on the ribbon of the Ribbon1 component.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Category: IRibbonCategory;
    RButton, SubButton1, SubButton2: IRibbonButton;
    SubItems: IRibbonElementsCollection;
Begin
    Self.BeginUpdate;
    Category := Ribbon1.ActiveCategory;
    RButton := New RibbonButton.Create;
    Category.Panels.Item(0).Elements.Add(RButton);
    RButton.ImageIndex := 0;
    RButton.LargeImageIndex := 0;
    RButton.Action := ActionItem1;
    RButton.Text := "Test";
    RButton.SplitButton := False;
    //Subelements
    SubButton1 := New RibbonButton.Create;
    SubButton2 := New RibbonButton.Create;
    SubItems := RButton.SubItems;
    SubItems.Add(SubButton1);
    SubItems.Add(SubButton2);
    SubButton1.Action := ActionItem1;
    SubButton2.Action := ActionItem1;
    SubButton1.Text := "Test 1";
    SubButton2.Text := "Test 2";
    Self.EndUpdate;
End Sub Button1OnClick;

Clicking the button creates a button on the active tab panel. Various properties are set up, and two subelements are created for the button.

See also:

IRibbonButton