Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to make datagridview Headers FONT BOLD?
Posted
Updated 16-Apr-10 23:43pm
v2

You can use following code to make datagridview headers font bold.


With dataGridView1.ColumnHeadersDefaultCellStyle
   .BackColor = Color.Navy
   .ForeColor = Color.White
   .Font = New Font(dataGridView1.Font, FontStyle.Bold)
End With


Hope this will help!
 
Share this answer
 
You asked the same question yesterday! I answered the question yesterday;

Set the ColumnHeadersDefaultCellStyle property for the datagridview.

What part do you not understand, did you even look at the documentation for DataGridView, or ColumnHeadersDefaultCellStlye?

You can set this property via the IDE at design time, or can apply the styling via code at run time. The ColumnHeadersDefaultCellStyle uses a DataGridViewStyle object, of which it has a Font property, which itself has a Bold property which can have the FontStyle.Bold applied.
 
Share this answer
 
in vb.net

VB
Dim dc As DataGridViewColumn = DataGridView1.Columns(i)
              dc.HeaderCell.Style.BackColor = Color.FromArgb(196, 196, 196)

              dc.HeaderCell.Style.ForeColor = Color.FromArgb(0, 0, 0)
              dc.HeaderCell.Style.Font = New Font("Arial", 12,FontStyle.Bold )
 
Share this answer
 
Comments
CHill60 14-Jul-15 6:25am    
Off topic somewhat, badly formatted, and 5 years late answering a post that is already answered
I haved try that but it failed, then i try disable the "visualSyles of header property"

With DataGridview
.EnableHeadersVisualStyles = False
.Font = New Font(dataGridView.Font, FontStyle.Bold)
end with

and it's success
hope this can help you
thanks
 
Share this answer
 
Comments
[no name] 26-Jul-13 8:24am    
Do you really think that he has waited 3 years for an answer? Especially when he already has an answer?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900