Solved

VB.net set Font Style and Size in DataGridView cell

Posted on 2013-01-05
1
9,470 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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.

705 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