GridViewCheckBoxColumn displays and allows editing of boolean data. The values are shown as checkboxes and allow the user to set or clear the checkboxes to toggle the underlying boolean data values. GridViewCheckBoxColumn inherits from GridViewDataColumn.
Copy[C#] Create and add GridViewCheckBoxColumn
GridViewCheckBoxColumn checkBoxColumn = new GridViewCheckBoxColumn();
checkBoxColumn.DataType = typeof(int);
checkBoxColumn.Name = "DiscontinuedColumn";
checkBoxColumn.FieldName = "Discontinued";
checkBoxColumn.HeaderText = "Discontinued?";
radGridView1.MasterTemplate.Columns.Add(checkBoxColumn);
Copy[VB.NET] Create and add GridViewCheckBoxColumn
Dim checkBoxColumn As New GridViewCheckBoxColumn()
checkBoxColumn.DataType = GetType(Integer)
checkBoxColumn.Name = "DiscontinuedColumn"
checkBoxColumn.FieldName = "Discontinued"
checkBoxColumn.HeaderText = "Discontinued?"
RadGridView1.MasterTemplate.Columns.Add(checkBoxColumn)
ValueChanged event
ValueChanged event can be used in particular about checkbox state change. You have to check the active editor type as in the example below:
Copy[C#]
void radGridView1_ValueChanged(object sender, EventArgs e)
{
if (this.radGridView1.ActiveEditor is RadCheckBoxEditor)
{
Console.WriteLine(this.radGridView1.CurrentCell.RowIndex);
Console.WriteLine(this.radGridView1.ActiveEditor.Value);
}
}
Copy[VB.NET]
Private Sub RadGridView1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGridView1.ValueChanged
If TypeOf Me.RadGridView1.ActiveEditor Is RadCheckBoxEditor Then
Console.WriteLine(Me.RadGridView1.CurrentCell.RowIndex)
Console.WriteLine(Me.RadGridView1.ActiveEditor.Value)
End If
End Sub