Search Results for

    Show / Hide Table of Contents

    Create Popup Button Control

    This example provides information on creating popup button controls in RobotStudio.

    Solution

    1. Create a RibbonGroup(string, string)

      // Create a new group in the ribbon for our buttons
      RibbonGroup ribbonPopUpGroup = new RibbonGroup("MyPopupButtonsGroup", "My Popup Button");
      
    2. Create a CommandBarPopup(string, string)

      // Create a new popup control
      CommandBarPopup popup = new CommandBarPopup("MyPopup", "MyPopup");
      popup.Enabled = CommandBarPopupEnableMode.Enabled;
      popup.Image = Image.FromFile(ReplaceWithValidImagePath);
      popup.HelpText = "Click here for more options.";
      ribbonPopUpGroup.Controls.Add(popup);
      
    3. Create CommandBarButton(string, string)

      // Create buttons that will later be added to the popup
      CommandBarButton buttonPath = new CommandBarButton("MyPath", "MyPath");
      buttonPath.DisplayAsCheckBox = true;
      buttonPath.DefaultEnabled = true;
      buttonPath.DefaultChecked = true;
      buttonPath.HelpText = "Toggle this to enable/disable this feature.";
      
      // Create another button
      CommandBarButton buttonTarget = new CommandBarButton("MyTarget", "MyTarget");
      buttonTarget.DisplayAsCheckBox = true;
      buttonTarget.DefaultEnabled = true;
      buttonTarget.DefaultChecked = true;
      buttonTarget.HelpText = "Toggle this to enable/disable this feature.";
      
    4. Attach event handler for command execution

      // Attach event handler for command execution to buttonPath
      buttonPath.ExecuteCommand += ButtonPath_ExecuteCommand;
      
    5. Add buttons to the CommandBarPopUp and to the active RibbonTab

      // Add buttons to popup control
      popup.Controls.Add(buttonPath);
      popup.Controls.Add(buttonTarget);
      
      // Add the entire group to the active ribbon tab
      UIEnvironment.ActiveRibbonTab.Groups.Add(ribbonPopUpGroup);
      

    Example

    This example provides information on creating popup button controls in RobotStudio.

    public void PopUpButtons()
    {
        // Begin UndoStep
        Project.UndoContext.BeginUndoStep("PopUpButtons");
    
        try
        {
            // Create a new group in the ribbon for our buttons
            RibbonGroup ribbonPopUpGroup = new RibbonGroup("MyPopupButtonsGroup", "My Popup Button");
    
            // Create a new popup control
            CommandBarPopup popup = new CommandBarPopup("MyPopup", "MyPopup");
            popup.Enabled = CommandBarPopupEnableMode.Enabled;
            popup.Image = Image.FromFile(ReplaceWithValidImagePath);
            popup.HelpText = "Click here for more options.";
            ribbonPopUpGroup.Controls.Add(popup);
    
            // Create buttons that will later be added to the popup
            CommandBarButton buttonPath = new CommandBarButton("MyPath", "MyPath");
            buttonPath.DisplayAsCheckBox = true;
            buttonPath.DefaultEnabled = true;
            buttonPath.DefaultChecked = true;
            buttonPath.HelpText = "Toggle this to enable/disable this feature.";
    
            // Create another button
            CommandBarButton buttonTarget = new CommandBarButton("MyTarget", "MyTarget");
            buttonTarget.DisplayAsCheckBox = true;
            buttonTarget.DefaultEnabled = true;
            buttonTarget.DefaultChecked = true;
            buttonTarget.HelpText = "Toggle this to enable/disable this feature.";
    
            // Attach event handler for command execution to buttonPath
            buttonPath.ExecuteCommand += ButtonPath_ExecuteCommand;
    
            // Add buttons to popup control
            popup.Controls.Add(buttonPath);
            popup.Controls.Add(buttonTarget);
    
            // Add the entire group to the active ribbon tab
            UIEnvironment.ActiveRibbonTab.Groups.Add(ribbonPopUpGroup);
        }
        catch
        {
            Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
            throw;
        }
        finally
        {
            Project.UndoContext.EndUndoStep();
        }
    }
    
    private static void ButtonPath_ExecuteCommand(object sender, ExecuteCommandEventArgs e)
    {
        // Toggle the checked state of the button upon execution
        CommandBarButton btn = sender as CommandBarButton;
        btn.DefaultChecked = !btn.IsChecked;
        Logger.AddMessage(new LogMessage("MyPath was toggled"));
    }
    

    Required Namespaces

    ABB.Robotics.RobotStudio.Environment

    See Also

    • Creating CustomButton
    • Removing Button
    In this article
    Back to top Copyright © 2026 ABB Robotics