Back to Devexpress

ASPxCheckBox.AllowGrayed Property

aspnet-devexpress-dot-web-dot-aspxcheckbox-5fdf833b.md

latest3.8 KB
Original Source

ASPxCheckBox.AllowGrayed Property

Gets or sets a value specifying whether the grayed state is available for a check box.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(false)]
public virtual bool AllowGrayed { get; set; }
vb
<DefaultValue(False)>
Public Overridable Property AllowGrayed As Boolean

Property Value

TypeDefaultDescription
Booleanfalse

true if the grayed state is available; otherwise, false.

|

Remarks

This property is a wrapper of the CheckBoxProperties.AllowGrayed property.

Example

This example illustrates how to customize ASPxCheckBox and GridViewDataCheckColumn if database data is kept in a format different from Boolean.

aspx
<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" DataSourceID="xds"
    KeyFieldName="Oid">
    <Columns>
        <dx:GridViewCommandColumn VisibleIndex="0" ShowEditButton="True"/>
        <dx:GridViewDataTextColumn FieldName="Oid" ReadOnly="True" VisibleIndex="1" SortOrder="Ascending">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="Title" VisibleIndex="2" Visible="false">
            <EditFormSettings Visible="True" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataCheckColumn FieldName="Allow" VisibleIndex="3">
            <PropertiesCheckEdit AllowGrayed="true" ValueType="System.String" ValueChecked="allowed"
                ValueUnchecked="not allowed" ValueGrayed="no information" />
        </dx:GridViewDataCheckColumn>
        <dx:GridViewDataCheckColumn FieldName="Active" VisibleIndex="4">
            <DataItemTemplate>
                <dx:ASPxCheckBox ID="chk" runat="server" AllowGrayed="true" ValueType="System.Int32"
                    ValueChecked="1" ValueUnchecked="-1" ValueGrayed="0" Value='<%# Eval("Active") %> '
                    OnInit="chk_Init">
                </dx:ASPxCheckBox>
            </DataItemTemplate>
            <EditFormSettings Visible="False" />
        </dx:GridViewDataCheckColumn>
    </Columns>
</dx:ASPxGridView>
<dx:XpoDataSource ID="xds" runat="server" TypeName="MyObject">
</dx:XpoDataSource>
csharp
static void CreateDefaultObjects() {
    using (UnitOfWork uow = GetNewUnitOfWork()) {
        MyObject obj = new MyObject(uow);
        obj.Title = "Test1";
        obj.Active = 1;
        obj.Allow = "allowed";

        obj = new MyObject(uow);
        obj.Title = "Test2";
        obj.Active = 0 ;
        obj.Allow = "allowed";

        obj = new MyObject(uow);
        obj.Title = "Test3";
        obj.Active = -1;
        obj.Allow = "no information";

        obj = new MyObject(uow);
        obj.Title = "Test4";
        obj.Active = 0;
        obj.Allow = "not allowed";

        uow.CommitChanges();
    }
}

See Also

AllowGrayedByClick

CheckState

GrayedImage

ValueGrayed

Check Box

ASPxCheckBox Class

ASPxCheckBox Members

DevExpress.Web Namespace