vb.net-从标签中删除粗体效果

vb.net-从标签中删除粗体效果,vb.net,fonts,Vb.net,Fonts,我的表格上有标签。单击粗体按钮时,我执行了以下操作以将其变为粗体: Dim con4 As Control For Each con4 In Me.Controls con4.Font = New Font(con4.Font, FontStyle.Bold) Next 这是有效的。现在,如果我再次单击同一按钮,我想删除粗体。 我想到的是一个If语句,如: If con4.FontStyle <> "Bold" Then con4.Fon

我的表格上有标签。单击粗体按钮时,我执行了以下操作以将其变为粗体:

Dim con4 As Control
For Each con4 In Me.Controls                
   con4.Font = New Font(con4.Font, FontStyle.Bold)
Next
这是有效的。现在,如果我再次单击同一按钮,我想删除粗体。 我想到的是一个If语句,如:

If con4.FontStyle <> "Bold" Then
   con4.Font = New Font(con4.Font, FontStyle.Bold)
End If
如果con4.FontStyle为“粗体”,则
con4.Font=新字体(con4.Font,FontStyle.Bold)
如果结束

但这不是VB.Net。如何用VB.Net语言编写上述语句?

此代码适合我

您只需使用条件
If Button.Font.Bold=True

Dim con4 As Control
If Button1.Font.Bold = True Then
    For Each con4 In Me.Controls
        con4.Font = New Font(con4.Font, FontStyle.Regular)
    Next
Else
    For Each con4 In Me.Controls
        con4.Font = New Font(con4.Font, FontStyle.Bold)
    Next
End If

您只能在for each中包含标签控件,并在
Label.Font.Bold

上指定条件,因为我的代码不完整,但它提供了此问题的最小值。请不要问我这没用。我也不知道怎么做,也许我会用一个变量。一个特定的
布尔
变量,它将确定它是否为
粗体