在VB.Net中更改Windows应用程序中所有窗体的字体大小
问题描述:
我已经使用Windows窗体创建了Windows应用程序,并且我有许多窗体。现在我想更改所有表单的字体大小,并且不可能进入每个表单并更改字体大小。在VB.Net中更改Windows应用程序中所有窗体的字体大小
所以,我需要知道是否有任何方法可以从一个地方更改所有窗体的字体大小。
感谢
答
只是略微增加这一点,如果你想改变所有的表单中的控件的字体,我几年前写的这一块,但已举行了相当不错...如果有帮助,请走一走?
形式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
即使你找到一个快速射击的方法来改变的一切形式的字体大小,它可能会变形,许多控件的布局。 –