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.v24.2.dll
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);
}