title: Detect in Control.GotFocus whether user navigates forward or backward?
body: <p>Having the following WinForms dialog form, I am handling the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.ongotfocus.aspx" rel="nofollow noreferrer"><code>GotFocus</code></a> event of <code>MyControl</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/DjSfw.png" alt="enter image description here"></p>
  
  <p><code>MyControl</code> derives from the DevExpress <a href="http://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraEditorsXtraUserControltopic" rel="nofollow noreferrer"><code>XtraUserControl</code></a> which in turn derives from the Microsoft WinForms standard <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.usercontrol%28v=vs.100%29.aspx" rel="nofollow noreferrer"><code>UserControl</code></a>.</p>
  
  <p>What I want to achieve is that when <code>MyControl</code> gets the focus when the user navigates with the <kbd>Tab</kbd> and <code>MyControl</code> gets the focus, that the focus is forwarded to the child controls. </p>
  
  <p>I do this successfully with the following code:</p>
  
  <pre><code>protected override void OnGotFocus(EventArgs e)
  {
      base.OnGotFocus(e);
  
      // Forward.
      foreach (Control control in Controls)
      {
          if (control.TabStop)
          {
              control.Select();
              break;
          }
      }
  }
  </code></pre>
  
  <p>I.e. if <code>Button 1</code> is focused and the user presses the <kbd>Tab</kbd> key, the focus is set to <code>Button 2</code>.</p>
  
  <p>What I'm <em>not</em> able to solve is if the user navigates backward. I.e. if <code>Button 4</code> is focused and the user presses the <kbd>Shift</kbd>+<kbd>Tab</kbd> keys, the focus should be set to <code>Button 3</code>.</p>
  
  <p><strong>My two questions are:</strong></p>
  
  <ul>
  <li>Is there a way to detect the navigation order of the user inside the <code>GotFocus</code> event?</li>
  <li>Am I doing it the right way at all? Maybe there is a built-in function/flag I can set to <code>MyControl</code> to automatically forward the focus to its child controls?</li>
  </ul>