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

Change column background color

1 Answer 1151 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jorge
Top achievements
Rank 1
Jorge asked on 02 Aug 2012, 07:47 AM
Hello
I'm using the code below to change the background color for a column in my grid.

With this I expected, after populating my grid with data (it is databoud to a datatable), that column "MyColumnName" will show all his cells backgroud in yellow color.

What I get is that I see the cells with the default background color (I'm using Office 2010 Black theme for the entire application), and I only see this column in yellow if I move the mouse over one row (when it highlights) in the column "MyColumnName" in this row alone. All the rest keep the default color.

Is there something I'm missing or doing wrong? I'm using Q2 2012.

Thank you in advance.
Private Sub MyGrid_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles MyGrid.CellFormatting
 
    If e.CellElement.ColumnInfo.Name = "MyColumnName" Then
        e.CellElement.BackColor = Color.Yellow
    Else
        e.CellElement.ResetValue(VisualElement.BackColorProperty, ValueResetFlags.Local)
    End If
 
End Sub



1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 06 Aug 2012, 12:04 PM
Hi Jorge,

Thank you for writing.

Please set and respectively reset the DrawFill property of the CellElement to get your color painted. More information regarding the formatting capabilities of RadGridView can be found here: http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html.

I hope this helps.
 
Kind regards,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Jorge
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or