)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

What is the purpose of the CheckBoxOptions property in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 18, 2019
Tags: checkbox

Purpose of checkbox option

The CheckBoxOptions.CheckedValue specifies the value to be given in the CellValue to check the checkbox, that is, either 1 or true. For example, when you want true to be checked and false to be unchecked.

By using GridModel

C#

// Change cell type to CheckBox
this.gridControl1[2, 3].CellType = "CheckBox";
// Set the values for ChekedValue and UncheckedValue
this.gridControl1[2, 3].CheckBoxOptions.CheckedValue = "true";
this.gridControl1[2, 3].CheckBoxOptions.UncheckedValue = "false";
// Set the CellValueType as bool.
this.gridControl1[2, 3].CellValueType = typeof(bool);
// set CellValue as true;
this.gridControl1[2, 3].CellValue = true;
// Add the description to the checkBox
this.gridControl1[2, 3].Description = "Click Me";

 

VB

' Change cell type to CheckBox
Me.gridControl1(2, 3).CellType = "CheckBox"
' Set the values for ChekedValue and UncheckedValue
Me.gridControl1(2, 3).CheckBoxOptions.CheckedValue = "true"
Me.gridControl1(2, 3).CheckBoxOptions.UncheckedValue = "false"
' Set the CellValueType as bool.
Me.gridControl1(2, 3).CellValueType = GetType(Boolean)
' set CellValue as true;
Me.gridControl1(2, 3).CellValue = True
' Add the description to the checkBox
Me.gridControl1(2, 3).Description = "Click Me"

 

By using QueryCellInfo event

C#

void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
    if(e.RowIndex==2 && e.ColIndex == 4)
    {
        //Change cell type to CheckBox
        e.Style.CellType = "CheckBox";
        // Set the values for ChekedValue and UncheckedValue 
        e.Style.CheckBoxOptions.CheckedValue = "true";
        e.Style.CheckBoxOptions.UncheckedValue = "false";
        // Set the CellValueType as bool.
        e.Style.CellValueType = typeof(bool);
        // Add the description to the checkBox
        e.Style.Description = "Enable";
    }
}

 

VB

Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
    If e.RowIndex=2 AndAlso e.ColIndex = 4 Then
        'Change cell type to CheckBox
        e.Style.CellType = "CheckBox"
        ' Set the values for ChekedValue and UncheckedValue
        e.Style.CheckBoxOptions.CheckedValue = "true"
        e.Style.CheckBoxOptions.UncheckedValue = "false"
        ' Set the CellValueType as bool.
        e.Style.CellValueType = GetType(Boolean)
        ' Add the description to the checkBox
        e.Style.Description = "Enable"
    End If
End Sub

 

Note:

Instead of true and false, you can also set 1 and 0 respectively to check and uncheck values in the similar way.

 

The following screenshot displays the CheckBox cell by using the CheckBoxOptions.

 Show the checkbox option in grid

 

Samples:

C#: CheckBoxOptionsProperty

VB: CheckBoxOptionsProperty

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon