Detect checkbox toggle change in telerik RadGridView?

404 views Asked by At

I have a checkbox column in radgridview, what do I want ? when checkbox is true then label1 turns red, when false label1 turns black.
this code snippet runs fine only when the checkbox column evaluates to true, whereas when false label1 shows no color change.

private void C_0_GridData_ValueChanged(object sender, EventArgs e)
{
    if (C_0_GridData.ActiveEditor is RadCheckBoxEditor)
    {
        label1.ForeColor = Color.Red;
    }
    else { label1.ForeColor = Color.Black; }
}

How to solve it?

1

There are 1 answers

4
Philipe On

finally, to detect whether checkboxcolumn in radgridview is in checked position or not, this simple code works as I expected:

private void C_0_GridData_CellValueChanged(object sender, GridViewCellEventArgs e)
    {
        bool completed = Convert.ToBoolean(C_0_GridData.Rows[e.RowIndex].Cells[0].Value.ToString());
        if (completed == true)
        { label1.ForeColor = Color.Red; }
        else
        { label1.ForeColor = Color.Black; }
    }

I put this code inside the CellValueChanged event, instead of using the ValueChanged event.