TommyTwoPints
asked on
Rich box text font
Hi experts
how can i change the font in my rich text box,
The following routines dont work in the way i want.
I want to be able to allow underline, bold and italic at once
Private Sub BBold_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BBold.Click
If Me.BBold.ImageIndex = 3 Then
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Bold)
Me.BBold.ImageIndex = 4
Else
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Regular)
Me.BBold.ImageIndex = 3
End If
End Sub
Private Sub BItalic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BItalic.Click
If Me.BItalic.ImageIndex = 5 Then
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Italic)
Me.BItalic.ImageIndex = 6
Else
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Regular)
Me.BItalic.ImageIndex = 5
End If
End Sub
Private Sub BUnderline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BUnderline.Click
If Me.BUnderline.ImageIndex = 7 Then
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Underline)
Me.BUnderline.ImageIndex = 8
Else
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Regular)
Me.BUnderline.ImageIndex = 7
End If
End Sub
These methods do not preserve the format. If the font was bold before underline is clicked; the boldness is removed and just underline is checked.
Cheers,
Tom
how can i change the font in my rich text box,
The following routines dont work in the way i want.
I want to be able to allow underline, bold and italic at once
Private Sub BBold_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BBold.Click
If Me.BBold.ImageIndex = 3 Then
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Bold)
Me.BBold.ImageIndex = 4
Else
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Regular)
Me.BBold.ImageIndex = 3
End If
End Sub
Private Sub BItalic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BItalic.Click
If Me.BItalic.ImageIndex = 5 Then
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Italic)
Me.BItalic.ImageIndex = 6
Else
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Regular)
Me.BItalic.ImageIndex = 5
End If
End Sub
Private Sub BUnderline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BUnderline.Click
If Me.BUnderline.ImageIndex = 7 Then
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Underline)
Me.BUnderline.ImageIndex = 8
Else
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font, FontStyle.Regular)
Me.BUnderline.ImageIndex = 7
End If
End Sub
These methods do not preserve the format. If the font was bold before underline is clicked; the boldness is removed and just underline is checked.
Cheers,
Tom
ASKER
no, i want to allow bold, italic and underline together.
Cheers.
Tom
Cheers.
Tom
for bold as an example do the new font like this.....
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font.F ontFamily, Me.RTBSendText.Font.SizeIn Points, Me.RTBSendText.Font.Style Or FontStyle.Bold)
for underline and italic ... change fontstyles.bold to the respective choices...
glad to be of service :)
Me.RTBSendText.Font = New Font(Me.RTBSendText.Font.F
for underline and italic ... change fontstyles.bold to the respective choices...
glad to be of service :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Alot:)
you're welcome :)
If RTBSendText.SelectionFont.
RTBSendText.SelectionFont = New Font(RTBSendText.Selection
Else
RTBSendText.SelectionFont = New Font(RTBSendText.Selection
End If