Solved

VB.net set Font Style and Size in DataGridView cell

Posted on 2013-01-05
1
9,106 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

680 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