/// /// Alternates the colors of the lines in a RichTextBox. Currently the colors are white and light pink. /// /// Text Box to be colored private void colorTextBox(RichTextBox box) { int startIndex = 0; // Index to the first character of the next line for (int lineNumber = 0; lineNumber < box.Lines.Count(); lineNumber++) { int curLineLength = box.Lines[lineNumber].Length; Color backgroundColor = lineNumber % 2 == 0 ? Color.White : Color.LightPink; box.Select(startIndex, curLineLength); box.SelectionBackColor = backgroundColor; box.DeselectAll(); box.Select(box.SelectionLength, 0); startIndex += curLineLength; // Skip to next line } }