Solved

VB.net set Font Style and Size in DataGridView cell

Posted on 2013-01-05
1
8,488 Views
Last Modified: 2013-01-05
Hi

I am using the following code to set the font in a DataGridView cell using the Fony Dialog.
The FontDialog also has Style (eg Bold) and Size. Is it possible to apply these to the DataGridView cell too? If so, what similar code would I use? Thanks

    Me.DataGridView1.Rows(oRowIndex).Cells(1).Style.Font = Me.FontDialog1.Font

I tried
    Me.DataGridView1.Rows(oRowIndex).Cells(1).Style.Font.Size = Me.FontDialog1.Font.Size
but get an error that "Property Size is read only"
0
Comment
Question by:murbro
1 Comment
 

Accepted Solution

by:
murbro earned 0 total points
ID: 38746426
Dim oFontName As String = Me.FontDialog1.Font.Name
                    Dim oFontSize As Integer = Me.FontDialog1.Font.Size
                    Dim oFontStyle As FontStyle = Me.FontDialog1.Font.Style
                    DataGridView1.Rows(oRowIndex).Cells(1).Style.Font = New Font(oFontName, oFontSize, oFontStyle)
                    'DataGridView1.Rows(oRowIndex).Cells(1).Style.Font = New Font("Arial", 12, FontStyle.Bold)
1

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

911 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

17 Experts available now in Live!

Get 1:1 Help Now