RichTextBox formatting as adding text

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

I use to know how to do this in VB4.. but its been so long since ive done
it... I want to take the Rich text box I have... then add a line of text in
blue and underlined... then the next line i want to add is normal formatted
(black and no styles applied) i need to this this for multiple entries of
information... how do i do this? basicly im building the contents of the
text box in a loop, the header line is blue and the message line is black..
thanks!

(example format)

Message Header [this line blue and underlined]
Message Text [normal text]
..
..
..
Reapeated again with different information here

thanks!
 
here's an example of what i am doing (not correct of course)

For Each drRow In dsEntries.Tables("Entries").Rows

' write out header

currStyle += Drawing.FontStyle.Underline

Me.rtbEntries.SelectionFont = New Drawing.Font(currFont, currStyle)

Me.rtbEntries.Text += "Event: " & DirectCast(drRow("eventdate"),
DateTime).ToShortDateString & " " & DirectCast(drRow("eventdate"),
DateTime).ToLongTimeString & " - " & Trim(drRow("creator")) & " - " &
Trim(drRow("eventactionname")) & ControlChars.CrLf



Me.rtbEntries.SelectionFont = New Drawing.Font(currFont,
Drawing.FontStyle.Regular)





Me.rtbEntries.ForeColor = Drawing.Color.Blue

Me.rtbEntries.Text += "Message: " & drRow("EventMessageText") &
ControlChars.CrLf

Me.rtbEntries.ForeColor = Drawing.Color.Black

Next
 
I think i figured it out, i changed the text property to selectedtext
property and appended form there and it formatted how i wanted it to once i
applied the formatting rules in the right places.


Brian Henry said:
here's an example of what i am doing (not correct of course)

For Each drRow In dsEntries.Tables("Entries").Rows

' write out header

currStyle += Drawing.FontStyle.Underline

Me.rtbEntries.SelectionFont = New Drawing.Font(currFont, currStyle)

Me.rtbEntries.Text += "Event: " & DirectCast(drRow("eventdate"),
DateTime).ToShortDateString & " " & DirectCast(drRow("eventdate"),
DateTime).ToLongTimeString & " - " & Trim(drRow("creator")) & " - " &
Trim(drRow("eventactionname")) & ControlChars.CrLf



Me.rtbEntries.SelectionFont = New Drawing.Font(currFont,
Drawing.FontStyle.Regular)





Me.rtbEntries.ForeColor = Drawing.Color.Blue

Me.rtbEntries.Text += "Message: " & drRow("EventMessageText") &
ControlChars.CrLf

Me.rtbEntries.ForeColor = Drawing.Color.Black

Next





Brian Henry said:
I use to know how to do this in VB4.. but its been so long since ive done
it... I want to take the Rich text box I have... then add a line of text in
blue and underlined... then the next line i want to add is normal formatted
(black and no styles applied) i need to this this for multiple entries of
information... how do i do this? basicly im building the contents of the
text box in a loop, the header line is blue and the message line is black..
thanks!

(example format)

Message Header [this line blue and underlined]
Message Text [normal text]
.
.
.
Reapeated again with different information here

thanks!
 
Back
Top