Skip to main content
Bar

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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

NuGet Package: DevExpress.Win.Navigation

#Declaration

[DefaultValue(0)]
public virtual int GroupIndex { get; set; }

#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:

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.

image

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);
}
See Also