Show / Hide Table of Contents

Creating a SplitButton

This example provides information on creating split buttons in RobotStudio.

Solution

  1. Create ribbon group for the split button

    // Create a ribbon group for buttons
    RibbonGroup ribbonGroup = new RibbonGroup("MySplitButtonsGroup", "My Split Button");
    
  2. Create button

    // Create button
    CommandBarButton button = new CommandBarButton("MyButton", "My main button");
    button.HelpText = "Click here for the main action";
    button.DefaultEnabled = true;
    
  3. Create CommandBarGalleryPopup button

    // Create gallery pop up 
    CommandBarGalleryPopup galleryPopup = new CommandBarGalleryPopup("MyGalleryPopup", "My Gallery PopUp");
    galleryPopup.Image = Image.FromFile(ReplaceWithValidImagePath);
    galleryPopup.Enabled = CommandBarPopupEnableMode.Enabled;
    galleryPopup.HelpText = "Choose an option";
    
  4. Assign the button to be displayed on the top portion of button, and set text position and size

    // Assign buttonSplit to the gallery pop up, displayed on the top portion of the split button
    galleryPopup.ClickButton = button;
    
    // Set text position and size of gallery
    galleryPopup.GalleryTextPosition = GalleryTextPosition.Right;
    galleryPopup.GalleryItemSize = new Size(120, 15);
    
  5. Add button to gallery control

    // Add button to gallery control
    galleryPopup.GalleryControls.Add(button);
    
  6. Add gallery control to ribbon group

    // Add gallery control to ribbon group
    ribbonGroup.Controls.Add(galleryPopup);
    
  7. Add ribbon group to ribbon tab

    // Add ribbon group to ribbon tab
    UIEnvironment.ActiveRibbonTab.Groups.Add(ribbonGroup);
    

Example

This example provides information on creating split buttons in RobotStudio.

public void SplitButton()
{
    // Begin UndoStep
    Project.UndoContext.BeginUndoStep("SplitButtons");

    try
    {
        // Create a ribbon group for buttons
        RibbonGroup ribbonGroup = new RibbonGroup("MySplitButtonsGroup", "My Split Button");

        // Create button
        CommandBarButton button = new CommandBarButton("MyButton", "My main button");
        button.HelpText = "Click here for the main action";
        button.DefaultEnabled = true;

        // Create gallery pop up 
        CommandBarGalleryPopup galleryPopup = new CommandBarGalleryPopup("MyGalleryPopup", "My Gallery PopUp");
        galleryPopup.Image = Image.FromFile(ReplaceWithValidImagePath);
        galleryPopup.Enabled = CommandBarPopupEnableMode.Enabled;
        galleryPopup.HelpText = "Choose an option";

        // Assign buttonSplit to the gallery pop up, displayed on the top portion of the split button
        galleryPopup.ClickButton = button;

        // Set text position and size of gallery
        galleryPopup.GalleryTextPosition = GalleryTextPosition.Right;
        galleryPopup.GalleryItemSize = new Size(120, 15);

        // Add button to gallery control
        galleryPopup.GalleryControls.Add(button);

        // Add gallery control to ribbon group
        ribbonGroup.Controls.Add(galleryPopup);

        // Add ribbon group to ribbon tab
        UIEnvironment.ActiveRibbonTab.Groups.Add(ribbonGroup);
    }
    catch
    {
        Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
        throw;
    }
    finally
    {
        Project.UndoContext.EndUndoStep();
    }
}

Required Namespaces

ABB.Robotics.RobotStudio.Environment

See Also

  • Creating PopupButton
  • Creating CustomButton
In this article
Back to top Copyright © 2025 ABB