Solved

VB.net set Font Style and Size in DataGridView cell

Posted on 2013-01-05
1
8,259 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
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…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

746 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

8 Experts available now in Live!

Get 1:1 Help Now