• North American Sales: 1-800-231-8588
  • Global Contacts
  • My Account
Infragistics Infragistics
Menu
  • North American Sales: 1-800-321-8588
  • My Account
    • Sign In/Register
  • Design & DevelopmentDesign & Develop
    • Best Value
      Infragistics Ultimate The complete toolkit for building high performing web, mobile and desktop apps.
      Indigo.Design Use a unified platform for visual design, UX prototyping, code generation and application development.
    • Web
      Ignite UI for Angular Ignite UI for JavaScript Ignite UI for React Ultimate UI for ASP.NET Indigo.Design
    • Desktop
      Ultimate UI for Windows Forms Ultimate UI for WPF
      Prototyping
      Indigo.Design
    • Mobile
      Ultimate UI for Xamarin Ultimate UI for iOS Ultimate UI for Android
    • Automated Testing Tools
      Test Automation for Micro Focus UFT: Windows Forms Test Automation for Micro Focus UFT: WPF Test Automation for IBM RFT: Windows Forms
  • UX
    • Indigo.Design Desktop Collaborative prototyping and remote usability testing for UX & usability professionals
    • Indigo.Design A Unified Platform for Visual Design, UX Prototyping, Code Generation, and App Development
  • Business Intelligence
    • Reveal Embedded Accelerate your time to market with powerful, beautiful dashboards into your apps
    • Reveal App Empower everyone in your organization to use data to make smarter business decisions
  • Team Productivity
  • Learn & Support Support
    • Help & Support Documents
    • Blogs
    • Forums
    • Product Ideas
    • Reference Applications
    • Customer Stories
    • Webinars
    • eBook & Whitepapers
    • Events
  • Free Trials
  • Pricing
    • Product Pricing / Buy Online
    • Renew Existing License
    • Contact Us
Windows Forms
  • Product Platforms
  • More
Windows Forms
Windows Forms Change Color of Column Headers in WinGrid
  • Blog
  • Files
  • Wiki
  • Members
  • Mentions
  • Tags
  • More
  • Cancel
  • New
Windows Forms requires membership for participation - click to join
  • Windows Forms
  • Best Practices for Placing a DropDown or Combo in an WinGrid Cell
  • Change Color of Column Headers in WinGrid
  • Disable WinGrid Row, Cell or Column with Activation Object
  • Performance in the WinTilePanel
  • Select All Rows in WinGrid Programatically
  • UI Thread Marshaling in the Model Layer
  • Using an WinGrid DataFilter to Convert Strings to Bools (and vice-versa) for a Checkbox Column

Change Color of Column Headers in WinGrid

Introduction

The UltraWinGrid column headers SupportThemes property is set to True by default.  This setting allows the grid to let the operating system draw certain aspects of the control with an XP theme. If you try to set the column headers of the grid to a custom color, they will be ignored.

There are two options for disabling the themed rendering, in turn, enabling the custom header colors to be drawn.

  1. Turn off SupportTheme - The benefit of this approach is that it is quite simple to do. The drawback is that now the entire grid will be drawn without those great-looking themes.
  2. Leave SupportThemes on but to prevent the column headers from being rendered with the XP themes. The benefit of this approach is that you can carefully select which elements of the grid are to be themed so that the grid does not have to lose its good looks entirely. The drawback is that the implementation is (ever so slightly) more complicated.

Below is a sample of the two ways to go about solving this problem.

C#

// One way to allow the column headers to show custom colors is to disallow the grid
// to use XP themes at all.
//
this.ultraGrid1.SupportThemes = false; 

//
// A more surgical approach would be to allow the grid to support XP themes, but to 
// disable themes just for the column headers.
//
this.ultraGrid1.SupportThemes = true;
foreach( UltraGridColumn col in this.ultraGrid1.DisplayLayout.Bands[0].Columns )
{
    // Here we "turn off" theming for the column header.
    col.Header.Appearance.ThemedElementAlpha = Infragistics.Win.Alpha.Transparent; 

    col.Header.Appearance.BackColor = Color.Azure;
    col.Header.Appearance.BackColorDisabled = Color.Orange;
} 

VB

' One way to allow the column headers to show custom colors is to disallow the grid
' to use XP themes at all.
'
Me.ultraGrid1.SupportThemes = False 

'
' A more surgical approach would be to allow the grid to support XP themes, but to 
' disable themes just for the column headers.
'
Me.ultraGrid1.SupportThemes = True
Dim col As UltraGridColumn
For Each col In Me.ultraGrid1.DisplayLayout.Bands(0).Columns 

' Here we "turn off" theming for the column header.
col.Header.Appearance.ThemedElementAlpha = Infragistics.Win.Alpha.Transparent 

col.Header.Appearance.BackColor = Color.Azure
col.Header.Appearance.BackColorDisabled = Color.Orange 
Next
  • WinGrid
  • Share
  • History
  • More
  • Cancel
Related
Recommended