title: How to set TextBox cursor position without SelectionStart
body: <p>I have a Windows Forms textbox with background thread updating its value every second.
  If I place cursor inside textbox it will loose its current position at next update. Same thing with text selection.</p>
  
  <p>I tried to solve it like that</p>
  
  <pre><code>    protected void SetTextProgrammatically(string value)
      {
          // save current cursor position and selection
          int start = textBox.SelectionStart;
          int length = textBox.SelectionLength;
  
          // update text
          textBox.Text = value;
  
          // restore cursor position and selection
          textBox.SelectionStart = start;
          textBox.SelectionLength = length;
      }
  </code></pre>
  
  <p>It works good most of the time. Here is situation when it does not work:<br /> 
  1) I place cursor at the end of the text in textbox<br />
  2) press SHIFT and move cursor to the left using &lt;- arrow key<br />
  Selection won't work properly. </p>
  
  <p>It looks like combination <code>SelectionStart=10</code> and <code>SelectionLength=1</code> automatically moves cursor to position 11 (not 10 as I want it to be).</p>
  
  <p>Please let me know if there is anything I can do about it! I am using Framework.NET 2.0.<br />
  There must be a way to set cursor position in textbox other then <code>SelectionStart+SelectionLength</code>.</p>