How to change dgv fonts on Buttton1_Click Event

aman_VB

Member
Joined
Apr 27, 2010
Messages
23
Programming Experience
1-3
Hi all,

How do you change the fonts of a dgv by selecting cells? Apparently I am doing something wrong here.


Private fontDlg As New FontDialog()
Private currFont As Font = Control.DefaultFont

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If fontDlg.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then
currFont = fontDlg.Font
dgv.SelectedCells.fonts = currFont '<--error message
Label1.Font = currFont '<---No error

End If
End Sub
 
VB.NET:
For Each cell As DataGridViewCell In Me.dgv.SelectedCells
    cell.Style.Font = Me.FontDialog1.Font
Next
 
Back
Top