Originally posted by SammyB
What were M$ smoking when they came up with that one?
Does that apply to the Font object in general, or a particular one (such as the one provided by SelectionFont)?
If RichTextBox1.SelectionFont.Style <> FontStyle.Bold Then RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, FontStyle.Bold) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, FontStyle.Regular) End If
If RichTextBox1.SelectionFont.Style <> FontStyle.Italic Then RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, FontStyle.Italic) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, FontStyle.Regular) End If
If RichTextBox1.SelectionFont.Style <> FontStyle.Underline Then RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, FontStyle.Underline) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, FontStyle.Regular) End If
Private Sub tlbItalic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbItalic.Click If RichTextBox1.SelectionFont.Style <> FontStyle.Italic Then RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Italic) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Regular) End If End Sub Private Sub tlbUnderline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbUnderline.Click If RichTextBox1.SelectionFont.Style <> FontStyle.Underline Then RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Underline) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Regular) End If End Sub Private Sub tlbStrikeout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbStrikeout.Click If RichTextBox1.SelectionFont.Style <> FontStyle.Strikeout Then RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Strikeout) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Regular) End If End Sub
Private Sub tlbItalic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbItalic.Click If RichTextBox1.SelectionFont.Style <> FontStyle.Italic Then RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Italic) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Regular) End If End Sub Private Sub tlbUnderline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbUnderline.Click If RichTextBox1.SelectionFont.Style <> FontStyle.Underline Then RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Underline) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Regular) End If End Sub Private Sub tlbStrikeout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbStrikeout.Click If RichTextBox1.SelectionFont.Style <> FontStyle.Strikeout Then RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Strikeout) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Regular) End If End Sub
Private Sub tlbBold_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbBold.Click RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, RichTextBox1.SelectionFont.Style Or FontStyle.Bold) End Sub Private Sub tlbItalic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbItalic.Click RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, RichTextBox1.SelectionFont.Style Or FontStyle.Italic) End Sub Private Sub tlbUnderline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbUnderline.Click RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, RichTextBox1.SelectionFont.Style Or FontStyle.Underline) End Sub Private Sub tlbStrikeout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tlbStrikeout.Click RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, RichTextBox1.SelectionFont.Style Or FontStyle.Strikeout) End Sub
Comment