This code is to set Backcolor to the Header of DataGridView
How to set a Size font and Bold to the text of ColumnHeadersvb Code:
Me.DataGridView3.ColumnHeadersDefaultCellStyle.BackColor = Color.White
Printable View
This code is to set Backcolor to the Header of DataGridView
How to set a Size font and Bold to the text of ColumnHeadersvb Code:
Me.DataGridView3.ColumnHeadersDefaultCellStyle.BackColor = Color.White
What other properties does ColumnheadersDefaultCellStyle have? Do you suppose one of them is a Font?
I tried this but didn't succeed.
vb Code:
Me.DataGridView1.ColumnHeadersDefaultCellStyle.Font.Bold = True Me.DataGridView1.ColumnHeadersDefaultCellStyle.Font.Size = 15
Font objects are immutable, i.e. once you've created one you cannot change it. You have to create a new Font object with the attributes you desire and then assign that to the Font property.
What do you think about this:
vb Code:
Dim FontBold As New Font(DataGridView1.ColumnHeadersDefaultCellStyle.Font, FontStyle.Bold) Me.DataGridView1.ColumnHeadersDefaultCellStyle.Font = FontBold Dim FontSize As New Font(DataGridView1.ColumnHeadersDefaultCellStyle.Font.Size, 15) Me.DataGridView1.ColumnHeadersDefaultCellStyle.Font = FontSize
I think that assigning two different Fonts to the same property is pointless because the second one simply replaces the first so why assign the first at all?
I can't understand what do you mean?
You create a Font and assign it to the property. Then you create another Font and assign it to the property. At the end of that the property will be equal to the second Font, so what was the point of assigning the first Font?
Do you mean I can assign tow properties in the same line?
No. I mean create one Font object and assign it to the Font property once. Just use whichever Font constructor that allows you to specify all the property values you need. The Font class has 13 constructors. It shouldn't be too hard to find one that suits your needs.
I think you mean like this:
vb Code:
Dim FontDefault As New Font("tahoma", 8, FontStyle.Regular)