title: Move cursor to "next" TextBox after n chars
body: <p>I am writing a .NET (4.0) app where user will be entering e.g. 2 digits in a number of <code>TextBox</code>es and I would like the cursor to automatically advance to the "next" TextBox after the second character is entered in one. What is the best way to implement this?</p>
  
  <p>EDIT: I have this<code>PreviewKeyDown</code> handler:</p>
  
  <pre><code>private void ODTextBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
  {
      if (allowedKeys.Contains(e.Key))
      {
          KeyConverter kc = new KeyConverter();
          string letter = kc.ConvertToString(e.Key);
          TextBox tb = (TextBox)sender;
  
          if (tb.Text.Length &gt; 1 &amp;&amp; tb.SelectedText.Length == 0)
          {
              this.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
          }
      }
  }
  </code></pre>
  
  <p>However, the <code>MoveFocus</code> method always causes the focus to be moved to the first of my 10 TextBoxes.  I have <code>TabIndex</code> and <code>KeyboardNavigation.TabIndex</code> set for every <code>TextBox</code>, but that does not help.</p>