title: Highlight Entire Line in RichTextBox C#
body: <p>I have a richtextbox in my C# winforms application and cannot figure out a way to highlight the entire line (the text part + any empty spaces).  I am only able to highlight the text on the line using the following code:</p>
  
  <pre><code>firstCharIndex = richTextBox.Text.IndexOf(header);
  headerLine = richTextBox.GetLineFromCharIndex(firstCharIndex);
  headerLineText = richTextBox.Lines[headerLine];
  
  int lastCharIndex = richTextBox.GetFirstCharIndexFromLine(headerLine + 1);
  
  //richTextBox.Select(firstCharIndex, headerLineText.Length);
  richTextBox.Select(firstCharIndex, lastCharIndex - firstCharIndex);
  
  if (richTextBox.SelectionBackColor != System.Drawing.Color.DarkGray)
  {
      richTextBox.SelectionBackColor = System.Drawing.Color.DarkGray;
  }
  </code></pre>