Back to Devexpress

XRCheckBox.CheckBoxState Property

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrcheckbox.md

latest3.5 KB
Original Source

XRCheckBox.CheckBoxState Property

Bindable. Gets or sets the current state of the XRCheckBox control.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
[DefaultValue(CheckBoxState.Unchecked)]
[SRCategory(ReportStringId.CatData)]
public CheckBoxState CheckBoxState { get; set; }
vb
<SRCategory(ReportStringId.CatData)>
<DefaultValue(CheckBoxState.Unchecked)>
Public Property CheckBoxState As CheckBoxState

Property Value

TypeDefaultDescription
CheckBoxStateUnchecked

An enumeration value that determines the state of a checkbox.

|

Available values:

NameDescription
Unchecked

The check box is unchecked.

| | Checked |

The check box is checked.

| | Indeterminate |

A visual state that signals to the user that the control state cannot be determined.

|

Remarks

The following image shows the checkbox control in different states:


Example

The following code sample creates the XRCheckBox control and binds its state to a data field.

csharp
using DevExpress.XtraReports.UI;
// ...

public XRCheckBox CreateXRCheckBox()
{
    // Creates the XRCheckBox control.
    XRCheckBox xrCheckBox1 = new XRCheckBox();

    xrCheckBox1.ExpressionBindings.AddRange(new ExpressionBinding[] {
    // Binds the CheckBoxState property to the UnitsInStock data field.
    new ExpressionBinding("BeforePrint", "CheckBoxState", "Iif([UnitsInStock]>=1,\'Checked\', \'Unchecked\')"),
    // Changes the control's text depending on the UnitsInStock data field value.
    new ExpressionBinding("BeforePrint", "Text", 
                          "Iif([UnitsInStock]>0,\'Units in Stock: \' + [UnitsInStock], \'None\')")});

    // Set the control size.
    xrCheckBox1.SizeF = new SizeF(150F, 20F);

    return xrCheckBox1;
}
vb
Imports DevExpress.XtraReports.UI
' ...

Public Function CreateXRCheckBox() As XRCheckBox
    ' Creates an XRCheckBox object.
    Dim xrCheckBox1 As New XRCheckBox()

    xrCheckBox1.ExpressionBindings.AddRange(New ExpressionBinding() {
    ' Binds the CheckState property to the UnitsInStock data field.
    New ExpressionBinding("BeforePrint", "CheckBoxState", "Iif([UnitsInStock]>=1,'Checked', 'Unchecked')"),
    ' Changes the control's text depending on the UnitsInStock data field value.
    New ExpressionBinding("BeforePrint", "Text",
                          "Iif([UnitsInStock]>0,'Units in Stock: ' + [UnitsInStock], 'None')")})

    ' Set the control size.
    xrCheckBox1.SizeF = New SizeF(150.0F, 20.0F)

    Return xrCheckBox1
End Function

See Also

Checked

XRCheckBox Class

XRCheckBox Members

DevExpress.XtraReports.UI Namespace