This is a migrated thread and some comments may be shown as answers.

RadGridView change Row color after cell CheckBox checked/unchecked

1 Answer 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
dan
Top achievements
Rank 1
dan asked on 09 May 2014, 03:57 PM
When i try to change Row color after checkbox checked my Row color changed only after i chaned another Row checkbox for example if i checked Row the color not changed and only after checked another Row the first Row color changed and same thing when unchecked.
Please see my code:

private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
{
     if ((bool)e.RowElement.RowInfo.Cells["Select"].Value == true)
     {
     e.RowElement.DrawFill = true;
     e.RowElement.GradientStyle = GradientStyles.Solid;
     e.RowElement.BackColor = Color.SkyBlue;
     }
     else
     {
     e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
     e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
     e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
     }
}

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 10 May 2014, 10:37 AM
Hi Dan,

Thank you for writing.

The check box editor in RadGridView and its value will be submitted to the underlying cell only when the current row is changed. To force this change, you can use the ValueChanged event of RadGridView:
void radGridView1_ValueChanged(object sender, EventArgs e)
{
    if (radGridView1.CurrentColumn.Name == "Select")
    {
        radGridView1.EndEdit();
    }
}

This will also trigger the formatting event, which will apply the desired formatting.

I hope that you find this information useful.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
dan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or