请问vb.net 中单击button一次加粗再次点击取消加粗的代码是怎样的? 麻烦

2025-04-05 08:32:56
推荐回答(2个)
回答1:

Dim i As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        i = i + 1
        If i = 1 Then
            TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Bold)
        Else
            TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Regular)
            i = 0
        End If
    End Sub

回答2:

上面的代码麻烦,用这种button1.font.bold.= not button1.font.bold纯手打,可能需要修改。