DataGridView: dynamic font size change

  • Thread starter Thread starter Lennart Nielsen
  • Start date Start date
L

Lennart Nielsen

How do you change the font size dynamically in a single selected cell?

Lennart
 
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
 
Back
Top