VB Express 2005
I have a richtextbox and wish to have:
1) The font for lines 1 - 4 should be BLACK
2) The font for lines > 4 should be RED
The above relates to visually lines and what one views on the screen and not carriage returns etc.
This is line 1 - BLACK FONT
This is line 2 - BLACK FONT
This is line 3 - BLACK FONT
This is line 4 - BLACK FONT
This is line 5 - RED FONT
This is line 6 - RED FONT
NOTE: This should be done for visual lines so if someone types in a very long line it will still work for word wrapping.
I will try and - BLACK
type in a very - BLACK
long line to - BLACK
show how I - BLACK
would like for - RED
this to work. - RED

RichTextBox - Font for visual lines > 4 should be RED
wjc
Thanks for you help but the above solution only works with carriage returns and not visual lines within the text.
Is it possible to do this with lines that we visuallly see on the screen and would take advantage of word-wrapping.
This is a line. This is a - FONT BLACK
a line. This is a line. - FONT BLACK
This is a line. This is a - FONT BLACK
line. This is a line. This - FONT BLACK
is a line. This is a line. - FONT RED
All visuall lines > 4 should be RED.
Thanks,
Rorro
Hi,
Is your problem solved
Thank you,
Bhanu.
InvalidSynTax
Okay, the following seems to work but you get a lot of flicker.
This will keep 'word wrap' or 'CRLF' line 5+ red, even if they go to the top
and delete a line. (Comment added/edited after initial post - The posting mechanism for this forum has word-wrapped one of the longer lines below at a '-' minus sign. Please be sure to join the two lines into one.)
Private
Sub RichTextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged ' If you have room for a small textbox on your form, uncomment the next line to watch what is happening ' TextBox1.Text = RichTextBox1.GetFirstCharIndexOfCurrentLine Try Dim x As Integer = RichTextBox1.SelectionStartRichTextBox1.Select(0, RichTextBox1.TextLength)
RichTextBox1.SelectionColor = Color.Black
RichTextBox1.DeselectAll()
RichTextBox1.Select(x, 0)
RichTextBox1.Select(RichTextBox1.GetFirstCharIndexFromLine(4), RichTextBox1.TextLength - RichTextBox1.GetFirstCharIndexFromLine(4))
RichTextBox1.SelectionColor = Color.Red
RichTextBox1.DeselectAll()
RichTextBox1.Select(x, 0)
Catch ex As Exception End Try End SubSathiya Sivam
RichTextBox1.SelectionColor = Color.Red
End If End Sub