We will see what is a gallery and how to use it.

Definition: A gallery is an array of elements of dimension defined by the fields “columns” and “rows”. The elements can be either image alone, with text or text only. It provides more freedom on how to display the elements. It is possible to define the height and width of the elements.

For example, consider a gallery control that shows a selection of pictures, as follows:

gallery example

How to create it?

This is specified using the following code

	    .Items(d =>
	          .AddItems(v =>

For simplicity the image are stored as project resources. To retrieve them, you will need to overwrite the method OnLoadImage and define based on the imageName parameter how the image will be retrieved.

    public override Bitmap OnLoadImage(string imageName)
        switch (imageName)
            case "desertImage":
                return Properties.Resources.Desert;
            case "forestImage":
                return Properties.Resources.Forest;
            case "toucanImage":
                return Properties.Resources.Toucan;
            case "treeImage":
                return Properties.Resources.Tree;
        return Properties.Resources.Island;


It is possible to apply the following events to a gallery

  • Visible: The condition requires to show the control
  • Enable: The condition requires to enable the control
  • Action: Define which action to take based on the current selected value
  • SelectedItemIndex: Get the index of the selected item. (Can get the index in the Action event)


  • Based on the position of the item clicked by the user, a message box will be displayed with a specific string
    protected override void CreateRibbonCommand(IRibbonCommands cmds)
        cmds.AddGalleryCommand("galleryIdOne").Action(position =>
            switch (position)
                case 0:
                    MessageBox.Show("Desert image clicked");
                case 1:
                    MessageBox.Show("Forest image clicked");
                case 2:
                    MessageBox.Show("Toucan image clicked");
                case 3:
                    MessageBox.Show("Tree image clicked");

Dynamic Items

When the content of the dropdown is defined dynamically, the following events need to be filled (at minimum the first 3)::

  • ItemCount: Get the number of item of the combo-box
  • ItemID: Get the ID of the item
  • ItemLabel: Get the label of the item
  • ItemImage: Get the image of the item (facultative)
  • ItemScreentip: Get the screentip of the item (facultative)
  • ItemSupertip: Get the enhanced screentip of the item (facultative)


A gallery with dynamic items will be create as follow in the method CreateFluentRibbon

    .Items(d =>
        d.AddGallery("Dynamic Gallery")

It is necessary to define how to items are populated and it needs to be defined in methods CreateRibbonCommand. Below is an example of it of 2 items populated dynamically.

    private int gallerySelectedIndex;

    protected override void CreateRibbonCommand(IRibbonCommands cmds)
            .ItemCounts(() => 2)
            .ItemsId(() => new object[] {"item1", "item2" })
            .ItemsLabel(() => new[] { "First Item", "Second Item" })
            // Images of numbers "one" and "two"
            .ItemsImage(() => new object[] {Properties.Resources.one, Properties.Resources.two})
            .ItemSelectionIndex(() => gallerySelectedIndex)
            .Action(i =>
            	gallerySelectedIndex = i;
                MessageBox.Show(@"Your selection: " + (i+1));


The following controls can be attached to a gallery

  • Item and button.