vb.net中的richtextbox如何按一个按钮,如果选定文本是粗体,就变为非粗体;否则变为粗

2024-12-22 00:23:13
推荐回答(1个)
回答1:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fon As String, fod As Single, fot As Boolean : fot = RichTextBox1.SelectionFont.Bold
fon = RichTextBox1.Font.Name : fod = RichTextBox1.Font.Size
If fot = True Then RichTextBox1.SelectionFont = New System.Drawing.Font(fon, fod, FontStyle.Regular)
If fot = False Then RichTextBox1.SelectionFont = New System.Drawing.Font(fon, fod, FontStyle.Bold)
End Sub