Richtextbox Selection BackColor
Posted on 2008-06-18
I am using a richtextbox that contains a string of letters that represents a strand of DNA. For example, CTTTGGGCCCCCC. I have set the selection.backcolor to yellow for the three Ts. I now have to assign a cost to each of the letters in the dna strand. So i am looping through the string, parsing the text into one letter at a time, and i need to test the color of the selected character. The first character C should have a selectedbackcolor of white, then the next three Ts should have a selectedbackcolor of yellow, then the rest of the string should be white. However, when i call the .select the Ts that used to be yellow get set to whatever the selectedbackcolor property is at the time. I would like them to stay yellow! Can anyone suggest a better method of getting the backcolor of the selected letter? Here is sample code:
For i = 0 To Me.RichTextBox1.TextLength - 1 'begin to loop thru string one character at a time
x = Me.RichTextBox1.Text.Substring(i, 1)
Me.RichTextBox1.Select(i, 1) 'select the character
Select Case Me.RichTextBox1.SelectionBackColor'