title: How can i get the selected text in a richTextBox using the mouse and display the text in real time?
body: <p>Today when I click with them mouse on the rich-textbox text window and drag the mouse to the right it's highlighting the text in blue.</p>
  
  <p>What I want to do is to simulate this situation but this time:</p>
  
  <ol>
  <li><p>To make when moving the mouse and highlighting text so it will be color in yellow not as by default blue.</p></li>
  <li><p>To make that while the mouse left button is clicked and pressed down nonstop and i move the mouse over a text show me this text in a label in real time.</p></li>
  </ol>
  
  <p>What I did so far:</p>
  
  <pre><code>private void richTextBox1_MouseDown(object sender, MouseEventArgs e)
          {
              if (e.Clicks == 1 &amp;&amp; e.Button == MouseButtons.Left)
              {
                  int positionStart = richTextBox1.GetCharIndexFromPosition
                                         (new Point(e.X, e.Y));
                  this.richTextBox1.SelectionStart = positionStart;
  
              }
          }
  </code></pre>
  
  <p>Not sure if mouse-down is the correct event and maybe i need to use also mouse-up event.
  Or maybe mouse move too.</p>
  
  <p>Now I have the SelectionStart index.</p>
  
  <p>But what should I do next ?</p>
  
  <p>Edit:</p>
  
  <p>For displaying in real time the selectedtext it's working but for coloring it in real time not working. I tried:</p>
  
  <pre><code>Font drawFont = new Font("Arial", 16);
          SolidBrush drawBrush = new SolidBrush(Color.Yellow);
          PointF drawPoint = new PointF(0, 0);
  
          protected override void OnPaint(PaintEventArgs e)
          {
              base.OnPaint(e);
              e.Graphics.DrawString(richTextBox1.SelectedText, drawFont, drawBrush,drawPoint);
          }
  </code></pre>
  
  <p>But it's not coloring anything at all.
  I checked with breakpoint it's getting there but not coloring any text.
  What i want is in in realtime when in the mousemove event it will color the selectedtext.</p>