I am writing a program which keeps notes on individual customer accounts. I am using a richtextbox which I have never work with before and have little knowledge of.
There are three types of notes kept(Problems, Memos and Quotes). Individual notes will be loaded from files in to a richtextbox sequentially from oldest to newest. The notes are availale to all users on a read-only basis and not editable in the RTB one logged.
I want to highlight all of the same note type headers in the same color with each type in a diffrent color. (eg Warning in Red, Memo in blue, Quote in green)
I have written code which loads the data and formats it as listed below. The code I listed for changing the color works, but it only works on the last instance of each heading type - not on all instances of each listed in the RTB.
I need to know how to modify this code to highlight all the same memo type headers to be the same color, not just one of each. I assume I have to loop through or set a different starting point but I'm not sure how to go about it.
Thanks in advance for any help!
wcwolff
Sample of RTB format:
PROBLEM ...date & time & by whom
message text...blah....blah...blah
MEMO ...date & time & by whom
message text...blah....blah...blah
QUOTATION ...date & time & by whom
message text...blah....blah...blah
PROBLEM ...date & time & by whom
message text...blah....blah...blah
Etc...
Code:
private sub....
*****
Code to load memo data here - newest to oldest
*****
Me.RTB.ForeColor = Color.Black ' sets all text to black
' highlight selected words
Me.RTB.SelectionStart = RTB.Find("warning")
Me.RTB.SelectionColor = Color.Red
Me.RTB.SelectionStart = RTB.Find("memo")
Me.RTB.SelectionColor = Color.Blue
Me.RTB.SelectionStart = RTB.Find("quote")
Me.RTB.SelectionColor = Color.Green
end sub
There are three types of notes kept(Problems, Memos and Quotes). Individual notes will be loaded from files in to a richtextbox sequentially from oldest to newest. The notes are availale to all users on a read-only basis and not editable in the RTB one logged.
I want to highlight all of the same note type headers in the same color with each type in a diffrent color. (eg Warning in Red, Memo in blue, Quote in green)
I have written code which loads the data and formats it as listed below. The code I listed for changing the color works, but it only works on the last instance of each heading type - not on all instances of each listed in the RTB.
I need to know how to modify this code to highlight all the same memo type headers to be the same color, not just one of each. I assume I have to loop through or set a different starting point but I'm not sure how to go about it.
Thanks in advance for any help!
wcwolff
Sample of RTB format:
PROBLEM ...date & time & by whom
message text...blah....blah...blah
MEMO ...date & time & by whom
message text...blah....blah...blah
QUOTATION ...date & time & by whom
message text...blah....blah...blah
PROBLEM ...date & time & by whom
message text...blah....blah...blah
Etc...
Code:
private sub....
*****
Code to load memo data here - newest to oldest
*****
Me.RTB.ForeColor = Color.Black ' sets all text to black
' highlight selected words
Me.RTB.SelectionStart = RTB.Find("warning")
Me.RTB.SelectionColor = Color.Red
Me.RTB.SelectionStart = RTB.Find("memo")
Me.RTB.SelectionColor = Color.Blue
Me.RTB.SelectionStart = RTB.Find("quote")
Me.RTB.SelectionColor = Color.Green
end sub