Solved

Changing color of data grid column headers only

Posted on 2011-03-08
5
341 Views
Last Modified: 2012-06-21
users would like to have all column headers only be in a color, but the values of each row be in white.
I have changed the Column Header Default Cell Style back color to yellow, and the default cell style back color to yellow as well and the header doesn't change color.  Does anyone have any suggestions?
0
Comment
Question by:LenTompkins
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Anil Golamari
ID: 35069692
we can change the color of the header in code by using

grid1.HeaderStyle.BackColor = Color.Yellow
0
 

Author Comment

by:LenTompkins
ID: 35070511
I forgot to tell you that this is a windows form and there is no Heade rStyle property for the grid.
0
 
LVL 18

Expert Comment

by:Anil Golamari
ID: 35072956
0
 
LVL 6

Accepted Solution

by:
nandithaa earned 500 total points
ID: 35079858
Column header color cannot be changed unless you set the "EnableHeadersVisualStyles " property of datagrid to "False".

Try this:
dataGridView1.EnableHeadersVisualStyles = false;
dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Yellow;

Open in new window

0
 

Author Closing Comment

by:LenTompkins
ID: 35083940
Perfect Thank you very much.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
fomat Json objects 6 28
C# replace string in void with dR["myData"].ToString() 3 42
Parse the OuterHTML Data in the txtfile using c# 4 49
DateTimepicker 4 33
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now