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

Changing background color of column headers

1 Answer 1330 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 22 Jun 2012, 04:22 PM
How do I programmically change the background color of the column headers in a DetailsView ListView? I know there is a VisualItemFormatting event, but I am not sure if the headers pass through this event.

1 Answer, 1 is accepted

Sort by
0
Boryana
Telerik team
answered on 26 Jun 2012, 02:58 PM
Hi Alan,

Thank you for writing.

You can use the CellFormatting event to set the BackColor property.
void radListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
{
    if (e.CellElement is DetailListViewHeaderCellElement)
    {
        e.CellElement.BackColor = Color.Red;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
}

Do not forget to reset the BackColor property if the cell element is not a details column header.

I hope this helps. Let me know if you have further questions.

Regards,
Boryana
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
ListView
Asked by
Alan
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Share this question
or