79157317

Date: 2024-11-04 23:57:14
Score: 1.5
Natty:
Report link

/// /// 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 } }

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Ken