November 20th, 2012, 07:00 AM
VB.Net rich text box font colors
I have a program receiving strings of data through the serial port.
I am needing to display these on a screen (within a text box) but some of the strings need to be different colours.
Is there an easy way to do this?
The trouble I am having is that each time I make the new string a different colour everything changes.... so... I have written a function to store the strings and then read through each and determine the colours, but.... this can be very slow, as each time a new string is received the program needs to re-do all the colours of the old ones (otherwise their colour would be incorrect).
Can anyone help?
November 26th, 2012, 02:03 PM
I replied to your other post in the VB section, so I'l re-post here :
How are you applying the color to the text?
I had a project a while back that involved formatting text in a rich text box and I remember that I had to select the section of text that I wanted to format first and then apply formatting to it similar to:
rtbViewOutput.SelectionStart = <some start point>
rtbViewOutput.SelectionLength = <some length of selection>
rtbViewOutput.SelectionColor = Color.Red
I know I had different formatting on different sections of text and I didn't have to re-assign previous formatting.
Hope that helps!