Version

Create Groups of Mutually-Exclusive StateButtons

A group of state buttons can be specified to be mutually exclusive by creating an OptionSet . Within the OptionSet, only one StateButton tool can be checked at a time. The OptionSet has an AllowAllUp property which determines whether one StateButton tool in the group is always required to be checked.

At Design Time

A new OptionSet can be created by selecting the OptionSets collection in the Properties window of the UltraToolBarsManager element. Then select the "New OptionSet" button and type in a key for the new OptionSet and specify a value for the AllowAllUp property. After the OptionSet has been created, the group of StateButton tools it will contain must be assigned to it. Right-click on the UltraToolBarsManager element and select 'Customize'. Go to the Tools tab and for each StateButton tool to be in the group, set the OptionSet property to the key of the OptionSet that was just created.

At Run Time

In Visual Basic:

Imports Infragistics.Win.UltraWinToolbars
...
Private Sub Create_Groups_of_Mutually_Exclusive_Statebuttons_Load( _
  ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles MyBase.Load
	' Create PopupMenuTool
	Dim menu1 As New PopupMenuTool("menu1")
	menu1.SharedProps.Caption = "Layout"
	' Creates a new OptionSet
	' AllowAllUp is set to True, so all state buttons can be
	' unchecked at the same time
	Me.UltraToolbarsManager1.OptionSets.Add(True, "option1")
	' Creates three new state button tools
	Dim Left As New StateButtonTool("Left")
	Left.SharedProps.Caption = "Left"
	Dim Center As New StateButtonTool("Center")
	Center.SharedProps.Caption = "Center"
	Dim Right As New StateButtonTool("Right")
	Right.SharedProps.Caption = "Right"
	' Adds tools to the tools collection
	Me.UltraToolbarsManager1.Tools.Add(Left)
	Me.UltraToolbarsManager1.Tools.Add(Center)
	Me.UltraToolbarsManager1.Tools.Add(Right)
	' Sets the 3 state button tools to be in the same OptionSet
	Left.OptionSet = Me.UltraToolbarsManager1.OptionSets("option1")
	Center.OptionSet = Me.UltraToolbarsManager1.OptionSets("option1")
	Right.OptionSet = Me.UltraToolbarsManager1.OptionSets("option1")
	' Adds the tools to a menu
	menu1.Tools.Add(Left)
	menu1.Tools.Add(Center)
	menu1.Tools.Add(Right)
	' Checkmarks will be displayed next to the state button tools in a menu
	Left.MenuDisplayStyle = StateButtonMenuDisplayStyle.DisplayCheckmark
	Center.MenuDisplayStyle = StateButtonMenuDisplayStyle.DisplayCheckmark
	Right.MenuDisplayStyle = StateButtonMenuDisplayStyle.DisplayCheckmark
	' Add the PopupMenuTool to tools collection
	Me.UltraToolbarsManager1.Tools.Add(menu1)
	' Add the PopupMenuTool to the Toolbar's tools collection
	Me.UltraToolbarsManager1.Toolbars(0).Tools.Add(menu1)
End Sub

In C#:

using Infragistics.Win.UltraWinToolbars;
...
private void Create_Groups_of_Mutually_Exclusive_Statebuttons_Load(
  object sender, EventArgs e)
{
	PopupMenuTool menu1 = new PopupMenuTool("menu1");
	menu1.SharedProps.Caption = "Layout";
	// Creates a new OptionSet
	// AllowAllUp is set to True, so all state buttons can be
	// unchecked at the same time
	this.ultraToolbarsManager1.OptionSets.Add(true, "option1");
	// Creates three new state button tools
	StateButtonTool Left = new StateButtonTool("Left");
	Left.SharedProps.Caption = "Left";
	StateButtonTool Center = new StateButtonTool("Center");
	Center.SharedProps.Caption = "Center";
	StateButtonTool Right = new StateButtonTool("Right");
	Right.SharedProps.Caption = "Right";
	// Adds tools to the tools collection
	this.ultraToolbarsManager1.Tools.Add(Left);
	this.ultraToolbarsManager1.Tools.Add(Center);
	this.ultraToolbarsManager1.Tools.Add(Right);
	// Sets the 3 state button tools to be in the same OptionSet
	Left.OptionSet = this.ultraToolbarsManager1.OptionSets["option1"];
	Center.OptionSet = this.ultraToolbarsManager1.OptionSets["option1"];
	Right.OptionSet = this.ultraToolbarsManager1.OptionSets["option1"];
	// Adds the tools to a menu
	menu1.Tools.Add(Left);
	menu1.Tools.Add(Center);
	menu1.Tools.Add(Right);
	// Checkmarks will be displayed next to the state button tools in a menu
	Left.MenuDisplayStyle = StateButtonMenuDisplayStyle.DisplayCheckmark;
	Center.MenuDisplayStyle = StateButtonMenuDisplayStyle.DisplayCheckmark;
	Right.MenuDisplayStyle = StateButtonMenuDisplayStyle.DisplayCheckmark;
	// Add the PopupMenuTool to tools collection
	this.ultraToolbarsManager1.Tools.Add(menu1);
	// Add the PopupMenuTool to the Toolbar's tools collection
	this.ultraToolbarsManager1.Toolbars[0].Tools.Add(menu1);
}