Back to Devexpress

BarCheckItem.CheckStyle Property

windowsforms-devexpress-dot-xtrabars-dot-barcheckitem-60794414.md

latest4.6 KB
Original Source

BarCheckItem.CheckStyle Property

Gets or sets the check box style. This property is not in effect for BarCheckItems displayed within sub-menus and popup menus.

Namespace : DevExpress.XtraBars

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(BarCheckStyles.Standard)]
[DXCategory("Appearance")]
public BarCheckStyles CheckStyle { get; set; }
vb
<DefaultValue(BarCheckStyles.Standard)>
<DXCategory("Appearance")>
Public Property CheckStyle As BarCheckStyles

Property Value

TypeDefaultDescription
DevExpress.XtraBars.BarCheckStylesStandard

A BarCheckStyles enumerator value that specifies the check box style.

|

Remarks

BarCheckItems displayed within bars and Ribbon controls do not initially have check boxes. Set the BarCheckItem.CheckBoxVisibility property to BeforeText or AfterText to show check boxes to the left or right of item captions.

To show radio buttons instead of check boxes, set the CheckStyle property to Radio.

The CheckStyle property only specifies the check box visual style (check box or radio button). This property does not combine BarCheckItems in a radio group. To create a radio group, set the GroupIndex property for each item to the same value.

Note

You cannot use the CheckStyle property to apply the Radio style to BarCheckItems displayed within sub-menus and popup menus.

Example

The following code combines two BarCheckItems in a radio group.

csharp
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);
}
vb
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim colorRadioGroupValue1 As Integer = 11

    BarCheckItem1.Caption = "Black"
    BarCheckItem1.CheckBoxVisibility = CheckBoxVisibility.BeforeText
    BarCheckItem1.CheckStyle = BarCheckStyles.Radio
    BarCheckItem1.GroupIndex = colorRadioGroupValue1
    AddHandler BarCheckItem1.CheckedChanged, AddressOf BarCheckItem_CheckedChanged

    BarCheckItem2.Caption = "White"
    BarCheckItem2.CheckBoxVisibility = CheckBoxVisibility.BeforeText
    BarCheckItem2.CheckStyle = BarCheckStyles.Radio
    BarCheckItem2.GroupIndex = colorRadioGroupValue1
    AddHandler BarCheckItem2.CheckedChanged, AddressOf BarCheckItem_CheckedChanged
    BarCheckItem2.Checked = True
End Sub

Private Sub BarCheckItem_CheckedChanged(ByVal sender As Object, ByVal e As ItemClickEventArgs)
    Dim checkItem As BarCheckItem = TryCast(sender, BarCheckItem)
    MessageBox.Show(checkItem.Caption)
End Sub

See Also

CheckBoxVisibility

GroupIndex

BarCheckItem Class

BarCheckItem Members

DevExpress.XtraBars Namespace