Home All Groups Group Topic Archive Search About

DataGridView: dynamic font size change

Author
5 Feb 2006 9:47 PM
Lennart Nielsen
How do you change the font size dynamically in a single selected cell?

Lennart

Author
6 Feb 2006 12:08 PM
Ken Tucker [MVP]
Hi,

        Try changing the cell style's font in the cell paint event.

    Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e
As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles
DataGridView1.CellPainting
        Try
            If DataGridView1.Item(e.ColumnIndex, e.RowIndex).Selected Then
                e.CellStyle.Font = New Font(Me.Font, FontStyle.Bold)
            Else
                e.CellStyle.Font = New Font(Me.Font, FontStyle.Regular)
            End If
        Catch
        End Try

    End Sub

Ken
----------------
Show quoteHide quote
"Lennart Nielsen" <lniel***@uni-systems.com> wrote in message
news:e9k0y2pKGHA.1124@TK2MSFTNGP10.phx.gbl...
> How do you change the font size dynamically in a single selected cell?
>
> Lennart
>