Skip to main content

CheckButton Class

A toggle button with checked and unchecked states that can be organized in mutually exclusive groups.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v25.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public class CheckButton :
    SimpleButton

Remarks

CheckButton toggles between checked and unchecked states when clicked.

Check Buttons - WinForms UI Controls, DevExpress

Use the Checked property to specify the button’s state. Handle the CheckedChanged event to respond to state changes.

Mutually Exclusive Groups

Assign the same non-negative value to the GroupIndex property to group buttons. Only one button in the group can be checked at a time. When a button is checked, other buttons in the group are unchecked automatically.

Clicking a checked button does nothing (default behavior). Set the AllowAllUnchecked property to true to allow users to uncheck it.

Focus Behavior

Set the AllowFocus property to false to prevent the button from receiving focus when clicked.

Example

The following example creates two button groups: one for user preference and one for skill level selection:

using DevExpress.XtraEditors;

// Group 0
checkButtonWantsToImprove.GroupIndex = 0;
checkButtonDoesntWantToImprove.GroupIndex = 0;

// Group 1
checkButtonBeginner.GroupIndex = 1;
checkButtonIntermediate.GroupIndex = 1;
checkButtonAdvanced.GroupIndex = 1;

checkButtonBeginner.CheckedChanged += (s, e) => {
    var button = (CheckButton)s;
    if (button.Checked)
        label1.Text = "Skill level: Beginner";
};

Inheritance

See Also