Runescope
Well-known member
- Joined
- Jan 6, 2011
- Messages
- 53
- Programming Experience
- Beginner
So what I've done is created a sub where I can format text going into a richtext control. It changes the font colour, size, and style. It works perfectly for the first text that goes into the control, but when I add a second set of text, it only changes the colour. I'm not sure what the problem is, it's becoming quite frustrating.
Here's the sub:
And here's what I'm testing it with:
"Test 1" appears properly no matter what settings I use, but "Test 2" will always default to 10 point fontsize and regular fontstyle, even though the colour changes to whatever I choose.
Anyone have any ideas?
Thanks in advance.
Here's the sub:
VB.NET:
Public Sub eFormat(eText As String, eColor As Color, eStyle As FontStyle, eSize As Single)
Dim intStartPos, intTxtLength As Integer
Dim eFont As FontFamily = frmEMail.txtEMailBody.SelectionFont.FontFamily
Dim newFont As New Font(eFont, eSize, eStyle, GraphicsUnit.Point)
intStartPos = Len(frmEMail.txtEMailBody.Text)
intTxtLength = Len(eText)
frmEMail.txtEMailBody.AppendText(eText)
frmEMail.txtEMailBody.Select(intStartPos, intTxtLength)
frmEMail.txtEMailBody.SelectionFont = newFont
frmEMail.txtEMailBody.SelectionColor = eColor
End Sub
And here's what I'm testing it with:
VB.NET:
eFormat("Test 1", Color.Black, FontStyle.Regular, 12)
eFormat("Test 2", Color.Blue, FontStyle.Italic, 8)
"Test 1" appears properly no matter what settings I use, but "Test 2" will always default to 10 point fontsize and regular fontstyle, even though the colour changes to whatever I choose.
Anyone have any ideas?
Thanks in advance.
Last edited: