title: Pressing tab moves to one after the next control
body: <p>I'm writing a simple wpf c# application for handling data in a database. A function that dynamically generates a <code>ComboBox</code> and a <code>Textbox</code> is executed from the <em>Main</em> <code>TextBox</code> when the tab-key is pressed down. Theoretically, it is supposed to switch focus to the next control, i.e. the newly generated <code>ComboBox</code>. Instead, when executed it moves to the latter generated <code>TextBox</code>. below is the code I have implemented.</p>
  
  <h2>Code Used:</h2>
  
  <pre><code>private void Add_PreviewMouseDown(object sender, MouseButtonEventArgs e) 
  {
      // insert generation code here
  }
  </code></pre>
  
  <p>The above function is called when tab is pressed through this:</p>
  
  <pre><code>private void MainTextbox_KeyDown(object sender, KeyEventArgs e)
  {
      if(e.Key == Key.Tab)
      {
          Add_PreviewMouseDown(null, null);
      }
  }
  </code></pre>
  
  <h2>Possible Reasons:</h2>
  
  <p>I think the issue might be with the time delay between the tab-key down and the process of creating the controls. Any thoughts?</p>