[]
A toggle button is a command button that allows the user to switch between two states. When a user clicks on a toggle button, it switches to the pressed/active state and on consecutive clicking, it returns back to the unpressed/inactive state.
The GIF below shows a toggle button with tooltip:
The Ribbon ToggleButton 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 ToggleButton using the Ribbon ToggleButton Floating ToolBar or by editing the properties in the Properties Window. For more information about floating toolbars, refer this topic.
The image below depicts the floating toolbar of Ribbon ToggleButton.
A toggle button can also be added to the C1Ribbon control through the code using the RibbonToggleButton class. This is depicted in the code below.
' Add toggle button to the format group
Dim leftAlign As RibbonToggleButton = New RibbonToggleButton(Image.FromFile("images\align_left.png"))
leftAlign.ToolTip = "Align your content with left margin."
formatGroup.Items.Add(leftAlign)
// Add toggle button to the format group
RibbonToggleButton leftAlign = new RibbonToggleButton(Image.FromFile(@"images\align_left.png"));
leftAlign.ToolTip = "Align your content with left margin.";
formatGroup.Items.Add(leftAlign);
A user can create groups of mutually exclusive Toggle Buttons in Ribbon control with the help of ToggleGroupName property of the RibbonToggleButton class.
Complete the following steps to create a Toggle Group:
Choose a Ribbon Group to which you would like to add a group of toggle buttons. Click on the Ribbon Group to activate its floating toolbar.
Click the Actions drop-down button. Select Add Toggle Button from the list. This adds a labeled toggle button on your Ribbon control.
Select the toggle button to activate the button's floating toolbar.
Click the Miscellaneous Settings button to open the Miscellaneous dialog box.
Enter a suitable group name for the ToggleGroupName property. Continue to build the group by adding more toggle buttons and setting their ToggleGroupName property to a common group name.
For instance, the Toggle Group Name depicted in the image is Edit.