Private Sub ChangeFontSize(ByVal FontSize As Single)
For Each objForm As Form In Me.MdiChildren
Dim currentFont As Font = objForm.Font
objForm.Font = New Font(currentFont.FontFamily, FontSize, currentFont.Style, currentFont.Unit)
Next
End Sub
Private Sub Form2_FontChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.FontChanged
Dim sngSize As Single = Me.Font.Size
For Each objControl As Control In Me.Controls
Dim currentFont As Font = objControl.Font
objControl.Font = New Font(currentFont.FontFamily, sngSize, currentFont.Style, currentFont.Unit)
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm1, frm2 As New Form2
frm1.MdiParent = Me
frm2.MdiParent = Me
frm1.Show()
frm2.Show()
ChangeFontSize(16)
End Sub
If TypeOf (objControl) Is DataGrid Then
Dim objDataGrid As DataGrid = CType(objControl, DataGrid)
'implement any DataGrid specific stuff
End If
For Each objForm As Form In Me.MdiChildren
For Each cntrl As Control In objForm
Dim currentFont As Font = objForm.Font
cntrl.Font = New Font(currentFont.FontFamily, 20, currentFont.Style, currentFont.Unit)
Next
Next
For Each objForm As Form In Me.MdiChildren
Dim currentFont As Font = objForm.Font
objForm.Font = New Font(currentFont.FontFamily, FontSize, currentFont.Style, currentFont.Unit)
For Each objControl As Control In objForm.Controls
objControl.Font = New Font(currentFont.FontFamily, FontSize, currentFont.Style, currentFont.Unit)
Next
Next
For Each objForm As Form In Me.MdiChildren
Dim currentFont As Font = objForm.Font
objForm.Font = New Font(currentFont.FontFamily, 10, currentFont.Style, currentFont.Unit)
For Each objControl As Control In objForm.Controls
objControl.Font = New Font(currentFont.FontFamily, 10, currentFont.Style, currentFont.Unit)
If TypeOf objControl Is TextBox Then CType(objControl, TextBox).Font = New Font(currentFont.FontFamily, 6, currentFont.Style, currentFont.Unit)
Next
Next
Private Sub ChangeFontSize(ByVal FontSize As Single)
For Each objForm As Form In Me.MdiChildren
Dim currentFont As Font = objForm.Font
objForm.Font = New Font(currentFont.FontFamily, FontSize, currentFont.Style, currentFont.Unit)
ChangeControlFontSize(FontSize, objForm.Controls)
Next
End Sub
Private Sub ChangeControlFontSize(ByVal FontSize As Single, ByVal Controls As Control.ControlCollection)
For Each objControl As Control In Controls
Dim currentFont As Font = objControl.Font
objControl.Font = New Font(currentFont.FontFamily, FontSize, currentFont.Style, currentFont.Unit)
ChangeControlFontSize(FontSize, objControl.Controls)
Next
End Sub
If TypeOf (objControl) Is DataGrid Then
Dim objDataGrid As DataGrid = CType(objControl, DataGrid)
'Do objDataGrid work.
End If