ComponentOne Ribbon for WinForms
Elements / Ribbon Items / Gallery
In This Topic
    Gallery
    In This Topic

    Gallery displays a collection of related commands in a Ribbon. The Gallery contains a list of clickable items. Each item when clicked shows the result visually on the selected text.

    The GIF below illustrates how the text changes upon applying various Styles from the Gallery.

    Gallery snapshot.

    The image below shows a gallery item in the C1Ribbon control.

    Gallery item.

    The Ribbon Gallery has a page-up and page-down button to scroll up and down the gallery. There is also a popup launcher button that opens a window with ribbon items.

    Configuring Gallery at Design-Time

    The Ribbon Gallery 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 Gallery using the Ribbon Gallery Floating ToolBar or by editing the properties of Gallery in the Properties Window. Refer this topic, for more information on floating toolbars. You can add items to Gallery using the RibbonGallery Items Collection Editor and RibbonGallery MenuItems Collection Editor. For more info on Collection Editors, refer this topic.

    The image below shows the floating toolbar of Gallery.

    Floating toolbar

    Adding Ribbon Gallery and Ribbon Gallery Items

    The user can also add Gallery and Gallery items in the C1Ribbon control through code using the RibbonGallery class and RibbonGalleryItem class. For instance, the code below depicts how to add a gallery of shapes to the Ribbon control.

    ' Add RibbonGallery ribbon item
    Dim ribbonGallery As RibbonGallery = New RibbonGallery()
    ribbonGallery.ToolTip = "Select a shape"
    Dim ribbonGallery1 As RibbonGalleryItem = New RibbonGalleryItem("Rectangle", Image.FromFile("images\rect.png"))
    Dim ribbonGallery2 As RibbonGalleryItem = New RibbonGalleryItem("Circle", Image.FromFile("images\circle.png"))
    Dim ribbonGallery3 As RibbonGalleryItem = New RibbonGalleryItem("Triangle", Image.FromFile("images\triangle.png"))
    Dim ribbonGallery4 As RibbonGalleryItem = New RibbonGalleryItem("Hexagon", Image.FromFile("images\hexagon.png"))
    ribbonGallery.Items.Add(ribbonGallery1)
    ribbonGallery.Items.Add(ribbonGallery2)
    ribbonGallery.Items.Add(ribbonGallery3)
    ribbonGallery.Items.Add(ribbonGallery4)
    formatGroup.Items.Add(ribbonGallery)
    
    // Add RibbonGallery ribbon item
    RibbonGallery ribbonGallery = new RibbonGallery();
    ribbonGallery.ToolTip = "Select a shape";
    RibbonGalleryItem ribbonGallery1 = new RibbonGalleryItem("Rectangle", Image.FromFile(@"images\rect.png"));
    RibbonGalleryItem ribbonGallery2 = new RibbonGalleryItem("Circle", Image.FromFile(@"images\circle.png"));
    RibbonGalleryItem ribbonGallery3 = new RibbonGalleryItem("Triangle", Image.FromFile(@"images\triangle.png"));
    RibbonGalleryItem ribbonGallery4 = new RibbonGalleryItem("Hexagon", Image.FromFile(@"images\hexagon.png"));
    ribbonGallery.Items.Add(ribbonGallery1);
    ribbonGallery.Items.Add(ribbonGallery2);
    ribbonGallery.Items.Add(ribbonGallery3);
    ribbonGallery.Items.Add(ribbonGallery4);
    formatGroup.Items.Add(ribbonGallery);
    

    The snapshot of the resulting ribbon control is shown below:

    Gallery ribbon.

    The user can change the position of the image and text of each gallery item. You can place the image above, before or after the text using the ImageAboveText, ImageBeforeText and ImageAfterText properties of GalleryItemTextImageRelation enum.
    Ribbon gallery item.

    You can also assign the position of image and text of each item in the gallery via code:

    ' Specify the position of text And image for gallery items
    ribbonGallery1.GalleryItemTextImageRelation = GalleryItemTextImageRelation.ImageBeforeText
    ribbonGallery2.GalleryItemTextImageRelation = GalleryItemTextImageRelation.ImageAfterText
    ribbonGallery3.GalleryItemTextImageRelation = GalleryItemTextImageRelation.ImageAboveText
    ribbonGallery4.GalleryItemTextImageRelation = GalleryItemTextImageRelation.ImageBeforeText
    
    // Specify the position of text and image for gallery items
    ribbonGallery1.GalleryItemTextImageRelation = GalleryItemTextImageRelation.ImageBeforeText;
    ribbonGallery2.GalleryItemTextImageRelation = GalleryItemTextImageRelation.ImageAfterText;
    ribbonGallery3.GalleryItemTextImageRelation = GalleryItemTextImageRelation.ImageAboveText;
    ribbonGallery4.GalleryItemTextImageRelation = GalleryItemTextImageRelation.ImageBeforeText;
    

    Gallery Grouping

    If you click on the popup launcher button, it displays a small window of gallery items, which are grouped by group names.

    The image below shows the popup gallery window with items arranged in two groups, Common and Extended.

    Gallery window.

    Grouping in gallery can be done at design time by assigning GroupName to each gallery item in the RibbonGallery Items Collection Editor.

    Gallery grouping.

    You can also assign group names to gallery items programmatically using the GroupName property of RibbonGalleryItem class. This is shown in the code snippet below:

    'Add gallery items to groups
    ribbonGallery1.GroupName = "Common"
    ribbonGallery2.GroupName = "Common"
    ribbonGallery3.GroupName = "Extended"
    ribbonGallery4.GroupName = "Extended"
    
    // Assign group names for different gallery items
    ribbonGallery1.GroupName = "Common";
    ribbonGallery2.GroupName = "Common";
    ribbonGallery3.GroupName = "Extended";
    ribbonGallery4.GroupName = "Extended";
    

    Gallery Zooming

    The C1Ribbon control supports zooming within the Gallery. The user can rest the cursor on each item and get a zoomed preview of that item image.

    Gallery zoom

    At design time, the zooming feature can be activated using the AllowZooming property of Ribbon Gallery in the Properties window. Note that for the zooming property to work, the ItemSize property of the Gallery should be less than the image size of each item.

    Zooming feature in gallery.

    You can also add the zooming feature via code using the AllowZooming property of RibbonGallery class.

    'Allow zooming in gallery
    ribbonGallery.AllowZooming = True
    
    // Add zooming feature to gallery item image
    ribbonGallery.AllowZooming = true;
    

    Gallery Filtering

    The C1Ribbon control supports filtering in the ribbon gallery. It allows you to filter items by gallery groups. This is illustrated in the GIF below:

    Filtering in gallery.

    At design time, the filtering feature can be activated using the AllowGroupFiltering property of Ribbon Gallery in the Properties window.

    Gallery showing filtering feature.

    You can also add the filtering feature via code using the AllowGroupFiltering property of RibbonGallery class.

    'Allow filtering in gallery groups
    ribbonGallery.AllowGroupFiltering = True
    
    // Allow gallery filtering 
    ribbonGallery.AllowGroupFiltering = true;
    
    Note: WinForms .NET 5 Edition has only runtime assemblies. Due to the new design-time model in VS2019 Preview, which is not complete yet from the Microsoft side, we do not supply any special design-time features as of yet. However, some of the controls might show up at design-time and allow editing few properties in the property grid.