Solved

VB.net set Font Style and Size in DataGridView cell

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb.net code 9 28
Create email hyperlinks from regular text 3 27
Cannot locate cell 15 41
Records being deleted when Condition Not Met 30 26
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

737 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