|
-
Nov 22nd, 2008, 09:41 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
This code is to set Backcolor to the Header of DataGridView
vb Code:
Me.DataGridView3.ColumnHeadersDefaultCellStyle.BackColor = Color.White
How to set a Size font and Bold to the text of ColumnHeaders
-
Nov 22nd, 2008, 10:53 PM
#2
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
What other properties does ColumnheadersDefaultCellStyle have? Do you suppose one of them is a Font?
-
Nov 22nd, 2008, 11:11 PM
#3
Thread Starter
Fanatic Member
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
I tried this but didn't succeed.
vb Code:
Me.DataGridView1.ColumnHeadersDefaultCellStyle.Font.Bold = True
Me.DataGridView1.ColumnHeadersDefaultCellStyle.Font.Size = 15
-
Nov 23rd, 2008, 02:44 AM
#4
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
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.
-
Nov 23rd, 2008, 01:10 PM
#5
Thread Starter
Fanatic Member
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
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
-
Nov 23rd, 2008, 05:23 PM
#6
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
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?
-
Nov 23rd, 2008, 06:08 PM
#7
Thread Starter
Fanatic Member
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
I can't understand what do you mean?
-
Nov 23rd, 2008, 06:15 PM
#8
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
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?
-
Nov 24th, 2008, 12:41 AM
#9
Thread Starter
Fanatic Member
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
Do you mean I can assign tow properties in the same line?
-
Nov 24th, 2008, 12:44 AM
#10
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
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.
-
Nov 24th, 2008, 09:42 AM
#11
Thread Starter
Fanatic Member
Re: [2005] How to set a Size font and Bold to the text of ColumnHeaders of DGV
I think you mean like this:
vb Code:
Dim FontDefault As New Font("tahoma", 8, FontStyle.Regular)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|