sarah
sarah

Reputation: 19

How to change the color of RadGridView header in C# WinForms?

I'm working on WinForms project. I need to change color of radGrid header from blue to green. every thing that I found, is about Web not Windows Forms.

Can any one please tell me how this can be achieved?

Thanks

Upvotes: 1

Views: 4634

Answers (3)

user314321
user314321

Reputation: 411

Heres what I use for what its worth.

in code objects edit like this.rgDailyResults.HeaderStyle =color.green or else you have tags in web and forms that control them like so:

<telerik:RadGrid ID="rgScenarioRollUps" AllowMultiRowSelection="True" AllowPaging="False" AllowSorting="False" Width="100px" AutoGenerateColumns="false" runat="server" Skin="">
    <HeaderStyle CssClass="propGridHeader" />
    <AlternatingItemStyle CssClass="propDarkGrid" />
    <ItemStyle CssClass="propLightGrid" />
    <SelectedItemStyle CssClass="propSelected" />

Edit This is what you wanted from telerik

http://www.telerik.com/help/winforms/

http://www.telerik.com/help/winforms/gridview-styling-and-appearance-changing-the-currentrow-indicator.html

the latter link explains changing the "header image"

Upvotes: 2

Try something like this:

C#

protected void radGrid_ItemDatabound(object sender, GridItemDataBoundEventArgs e)
{
    if (e.Item is GridHeaderItem)
    {
        var item = e.Item as GridHeaderItem;
        item.BackColor = Color.Green;
    }
}

ASPX:

<telerik:RadGrid ID="radGrid" runat="server" OnItemDataBound="radGrid_ItemDatabound">
[...]
</telerik:RadGrid>

Upvotes: 0

Arun Bertil
Arun Bertil

Reputation: 4648

Try

GridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Purple;

Upvotes: 0

Related Questions