Ribbon Gallery control - How to use it?

Add-in Express™ Support Service
That's what is more important than anything else

Ribbon Gallery control - How to use it?
 
Subscribe
Steve Faleiro




Posts: 15
Joined: 2024-09-12
TadxRibbonGallery - How to use this control? I added items to the control. I want the user to select an item and then it should perform an action. When I see the events list there is:
+ OnChange
+ OnItemPropertyChanging
+ OnPropertyChanging

The OnChange event seems to be firing when I select an item. But how to go from there?

This is the method signature :-

procedure TAddInModule.MyRibbonControlOnChange(Sender: TObject;
    const RibbonControl: IRibbonControl);
begin
 // How to I get the item that was clicked? 
end;


Note that I am populating the items in this control from a database. I will set the Tag property to a unique ID. Then when the item is clicked, I need to know which one was clicked.
Posted 21 Sep, 2024 23:39:55 Top
Dmitry Kostochko


Add-in Express team


Posts: 2887
Joined: 2004-04-05
Hello Steve,

Thank you for the detailed description. You can use the SelectedItemIndex property of the TadxRibbonGallery object. Please have a look at the code sample below:

procedure TAddInModule.MyRibbonControlOnChange(Sender: TObject; 
    const RibbonControl: IRibbonControl);
var
  Item: TadxRibbonItem;
begin
  Item := TadxRibbonGallery(Sender).Items[TadxRibbonGallery(Sender).SelectedItemIndex];

  if Assigned(Item) then begin
    ShowMessage('Caption: ' + Item.Caption + ' Tag: ' + Item.Tag.ToString());

  end;
...
Posted 23 Sep, 2024 15:30:43 Top