BarBaseButtonItem.GroupIndex Property
Gets or sets the button’s group index. This property is in effect when the current object acts as a check button.
Namespace: DevExpress.XtraBars
Assembly: DevExpress.XtraBars.v20.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Property Value
Type | Default | Description |
---|---|---|
Int32 | 0 | The button’s group index. |
Remarks
The GroupIndex property allows you to create a radio group of check buttons. When a user selects one item, other items in the group are automatically deselected.
The GroupIndex property is in effect for BarBaseButtonItems that act like check buttons. These items include the following:
- BarCheckItems
- BarButtonItem objects, whose BarButtonItem.ButtonStyle property is set to BarButtonStyle.Check.
To combine two or more check buttons in a radio group, set the GroupIndex property for these buttons to the same non-zero value.
The BarBaseButtonItem.AllowAllUp property determines if all items in a group can be deselected simultaneously.
Example
The following code combines two BarCheckItems in a radio group.
private void Form1_Load(object sender, EventArgs e) {
int colorRadioGroupValue1 = 11;
barCheckItem1.Caption = "Black";
barCheckItem1.CheckBoxVisibility = CheckBoxVisibility.BeforeText;
barCheckItem1.CheckStyle = BarCheckStyles.Radio;
barCheckItem1.GroupIndex = colorRadioGroupValue1;
barCheckItem1.CheckedChanged += BarCheckItem_CheckedChanged;
barCheckItem2.Caption = "White";
barCheckItem2.CheckBoxVisibility = CheckBoxVisibility.BeforeText;
barCheckItem2.CheckStyle = BarCheckStyles.Radio;
barCheckItem2.GroupIndex = colorRadioGroupValue1;
barCheckItem2.CheckedChanged += BarCheckItem_CheckedChanged;
barCheckItem2.Checked = true;
}
private void BarCheckItem_CheckedChanged(object sender, ItemClickEventArgs e) {
BarCheckItem checkItem = sender as BarCheckItem;
MessageBox.Show(checkItem.Caption);
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the GroupIndex property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.