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

GridViewCheckBoxColumn Hides Row Selection Color

3 Answers 151 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 14 Jul 2016, 11:14 PM

When one or more rows are selected in a RadGridView, their cell backgrounds change to (by default) a pale orange color, with gradation I think.  But, when this happens, the backgrounds of those cells of the selected rows that are in GridViewCheckBoxColumns remain white.  I want to show the row selection color in the GridViewCheckBoxColumn cells, to make them consistent with the other cells in the selected rows.

I think the problem is that the embedded CheckBox completely fills the cell, obscuring the cell background proper.  If that is the case, then perhaps a solution would be to set the CheckBox's own background to transparent, so that the underlying cell color changes (when the row is selected and deselected) would be visible. 

If all that is true, then what I specifically want to know is how to set the background color of the embedded CheckBox in every cell of every GridViewCheckBoxColumn in the grid to transparent when the grid is shown.

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan Nenchev
Telerik team
answered on 19 Jul 2016, 08:47 AM
Hello Simon,

Please have in mind that the GridViewCheckBoxColumn does not use a CheckBox but a GridViewCheckBox element as a default editor. With this in mind, in order to achieve the desired behavior, you need to edit the ControlTemplate of the GridViewCheckBox, inspect the whole structure and set some of the elements` backgrounds to transparent. I have created a sample project that implements the desired behavior. 

You can also use a GridViewDataColumn and explicitly set its CellTemplate to contain a standard CheckBox. Eventually, you can change its control template(as in the GridViewCheckBoxColumn) or directly set the background color:

<telerik:GridViewDataColumn DataMemberBinding="{Binding IsChampion}">
                   <telerik:GridViewDataColumn.CellTemplate>
                       <DataTemplate>
                           <CheckBox IsChecked="{Binding IsChampion}" Background="Transparent"></CheckBox>
                       </DataTemplate>
                   </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

However, this will not change all components(within the CheckBox template) backgrounds so modifying the whole template is the best approach. I have created a sample project for your reference with these two approaches. Please review it and consider which one suits your scenario the best.

Please update me whether the information was useful. Of course, if you have any further questions or concerns, do not hesitate to contact us.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Simon
Top achievements
Rank 1
answered on 18 Sep 2016, 08:16 PM

Thanks, Stefan. Sorry to be so late replying.  Forum thread tracking is not working for me, so I did not see your post at the time.  And, for reasons unrelated to this thread but to do with specific application requirements, we have decided not to implement the check boxes in the grids with GridViewCheckBoxColumn.  Instead, we have developed our own unsophisticated alternative that will meet our needs.

So we have not implemented your solution in our application.  However, I have looked at and ran your sample application.  It does exactly what I was asking for.

Your sample provides solutions for both GridViewCheckBoxColumn and Checkbox.  They both work.  Our application's grids have many check boxes.  We did try implementing them with Checkbox but encountered slow grid building and scrolling performance.  There were no such performance problems with either GridViewCheckBoxColumn or our light-weight custom solution.  I mention this not at all as a criticism of the solution sample, but just as something anyone implementing a RadGridView with many check boxes should consider.

Cheers, Simon

0
Stefan Nenchev
Telerik team
answered on 20 Sep 2016, 08:16 AM
Hi Simon,

Thanks for the update and sharing the additional information. I am glad to hear that you have found a solution to your requirement as well. I just wanted to correct a statement from my previous reply - actually, the GridViewCheckBoxColumn uses a GridViewCheckBox in view mode and a standard CheckBox when in edit mode.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Simon
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Simon
Top achievements
Rank 1
Share this question
or