The requested page is not available for the requested platform. You are viewing the content for Default platform.

XRCheckBox Class

A Checkbox control.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

[DefaultBindableProperty("CheckState")]
public class XRCheckBox :
    XRFieldEmbeddableControl,
    IEditOptionsContainer
<DefaultBindableProperty("CheckState")>
Public Class XRCheckBox
    Inherits XRFieldEmbeddableControl
    Implements IEditOptionsContainer

Remarks

The CheckState property specifies the checkbox state:

report-control-check-box

The Checked property indicates whether the checkbox is checked (displays a check mark) or not (is empty). This property returns true for the Indeterminate state.

The Text property specifies the checkbox caption. Double-click the checkbox to invoke its in-place editor and type the caption text.

report-control-check-box-text

Bind to Data

Drag a Boolean field from the Field List onto your report. This adds a new checkbox to your report and binds its CheckState property to the dragged field.

report-control-check-box-add-from-toolbox

If you added a checkbox from the Toolbox, click the control's smart tag, expand the CheckState property's Expression drop-down list and select a data field. This binds your control's CheckState property to a data source field.

report-control-check-box-bind-to-data

The data field value determines the checkbox state:

  • True or 1 - activates the Checked state;
  • False or 0 - activates the Unchecked state;
  • Any other value - activates the Indeterminate state.

You can bind the checkbox caption to a data source field. Click the control's smart tag, expand the Text property's Expression drop-down list and select the data field.

The Expression option's ellipsis button invokes the Expression Editor. This Editor allows you to construct a complex binding expression with two or more fields.

report-control-check-box-bind-to-data

Refer to the Bind Report Controls to Data topic for more information about the available data binding modes and how to create data-aware controls.

Interactivity

Change the EditOptions.Enabled option to specify if users can [change the checkbox state(xref:117343)] in Print Preview.

report-control-check-box-interactivity

You can create checkbox groups to make them behave like radio lists. To group checkboxes, set their CheckEditOptions.GroupID properties to a group ID value.

report-control-check-box-interactivity

Customization

The XRCheckBox.GlyphOptions property provides access to glyph settings.

  • Style - specifies a predefined glyph style.

    report-control-check-box-customization

  • Alignment - specifies the glyph alignment within the control.

    report-control-check-box-customization

  • Size - specifies the glyph size.

  • CustomGlyphs - specifies a custom glyph image for each checkbox state (Checked/Unchecked/Indeterminate).

Examples

The code sample below illustrates how to create an XRCheckBox control for a report.

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

public XRCheckBox CreateXRCheckBox()
{
    // Create an XRCheckBox control.
    XRCheckBox xrCheckBox1 = new XRCheckBox();

    xrCheckBox1.ExpressionBindings.AddRange(new ExpressionBinding[] {
    // Bind the CheckState property to the UnitsInStock data field.
    new ExpressionBinding("BeforePrint", "CheckState", "Iif([UnitsInStock]>=1,\'Checked\', \'Unchecked\')"),
    // Change 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;
}

Implements

DevExpress.XtraPrinting.IBrickOwner
DevExpress.Utils.Serializing.Helpers.IXtraSupportDeserializeCollectionItem
DevExpress.Utils.Serializing.IXtraSerializable
See Also