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

Change row color with GridViewCheckBoxColumn selected

2 Answers 68 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rodrigo
Top achievements
Rank 1
Rodrigo asked on 20 Oct 2015, 11:22 AM

I have a GridView with MultiSelect enabled. The standard behavior is when the user selects a row this changes the row's color and all selected rows maintain a diferent color. I want to mimic this behavior with a GridViewCheckBoxColumn.

 My GridView has a GridViewCheckBoxColumn and when it's checked, I want to change the row color. If it's unchecked, return it back to normal. Currently I'm using the ValueChanged event to capture the event of the checking and unchecking.

private void radGridViewProducts_ValueChanged(object sender, EventArgs e)
{
    if (this.radGridViewProducts.ActiveEditor is RadCheckBoxEditor)
    {
        this.radGridViewProducts.Rows[this.radGridViewProducts.CurrentCell.RowIndex].IsSelected = true;
    }
}

 The code above does not change the row color. How can I acheive this?

 

Thank you.

2 Answers, 1 is accepted

Sort by
0
Andreas Haeusler
Top achievements
Rank 2
answered on 20 Oct 2015, 11:57 AM

My uneducated guess:

​As with most of the formatting: Use the CellFormatting event, check the e.CellElement.RowInfo for the state of your GridViewCheckBoxColumn and format accordingly.

 

As a little kickstart check http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html

 

One of the telerik folks will certainly provide more detailed feedback soon. 

 

0
Dimitar
Telerik team
answered on 21 Oct 2015, 08:32 AM
Hi Rodrigo,

Thank you for writing.

An example for this is available in the following article: Formatting Rows

In addition, you should set the EditMode property of the checkbox column. This way the change will be applied immediately:
GridViewCheckBoxColumn col = radGridView1.Columns[0] as GridViewCheckBoxColumn;
col.EditMode = EditMode.OnValueChange;

I hope this helps.

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Rodrigo
Top achievements
Rank 1
Answers by
Andreas Haeusler
Top achievements
Rank 2
Dimitar
Telerik team
Share this question
or