我已经使用Windows窗体创建了Windows应用程序,我有很多形式。现在我想更改所有表单的字体大小,并且无法进入每个表单并更改字体大小。
所以,我需要知道有没有办法从一个地方改变所有表格的字体大小。
由于
答案 0 :(得分:0)
只是稍微补充一点,如果你想改变表格中所有控件的字体,几年前我写了这篇文章,但是已经很好了......如果有帮助就去吧?
只需调用表单Load_Event ..或任何您需要的地方
Public Sub Form_Load()
Checkfont(Me)
End Sub
Public DifferentFont As Font = New Font("Times New Roman", 10)
Public Sub CheckFont(frm As Form)
If Not USE_Different_Font Then Exit Sub
For Each ctl As Control In frm.Controls
If ctl.HasChildren Then
CheckFont_Children(ctl)
End If
Try
ctl.Font = DifferentFont
Catch ex As Exception
End Try
Next
End Sub
Private Sub CheckFont_Children(parent As Control)
For Each ctl In parent.Controls
If ctl.HasChildren Then
CheckFont_Children(ctl)
End If
Try
ctl.font = DifferentFont 'New Font(DifferentFont.FontFamily, DifferentFont.Size)
Catch ex As Exception
End Try
Next
End Sub