title: C# MDI WinForms child activation
body: <p>The problem I have is that when one switches from one child form to another a strange thing happens: the form to be shown appears in a strange way as if it has been minimized, restored and then maximized, causing an effect of like several drawing events at the same time.</p>
  
  <p>The problem does not appear (ie, everything works) in these situations:</p>
  
  <ul>
  <li>when one switches between forms using <kbd>CTRL</kbd>+<kbd>TAB</kbd> or <kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>TAB</kbd></li>
  <li>when child forms are not maximized and one simply changes the order/position of the form</li>
  </ul>
  
  <p>Possibly related; there are a tonne of methods one can called for showing forms, including (and related):</p>
  
  <ul>
  <li><code>child.Focus()</code></li>
  <li><code>child.Show()</code></li>
  <li><code>child.Activate()</code></li>
  <li><code>child.Select()</code></li>
  <li><code>child.BringToFront()</code></li>
  </ul>
  
  <p>My question is, what exactly should I be calling?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>In my case, I have the following code that works, but still causes the weird effect I described above:</p>
  
  <pre><code>private void tabForms_MouseClick(object sender, MouseEventArgs e)
  {
      // handle middle-mouse-button click (close)
      if (e.Button == System.Windows.Forms.MouseButtons.Middle)
      {
          // See: http://stackoverflow.com/a/745361
          TabPage tab = tabForms.TabPages.Cast&lt;TabPage&gt;().Where((t, i) =&gt; tabForms.GetTabRect(i).Contains(e.Location)).FirstOrDefault();
          if (tab != null &amp;&amp; tab.Tag != null) (tab.Tag as Form).Close();
      }
      // handle left-mouse-button click (show)
      if ((tabForms.SelectedTab != null) &amp;&amp; (tabForms.SelectedTab.Tag != null) &amp;&amp; (ActiveMdiChild != tabForms.SelectedTab.Tag))
      {
          (tabForms.SelectedTab.Tag as Form).Select();
          (tabForms.SelectedTab.Tag as Form).Show();
      }
  }
  </code></pre>
  
  <p><strong>PS:</strong> Without the <code>.Select()</code> it doesn't work. Although it seems that it still works if I replace <code>.Select()</code> and <code>.Show()</code> with <code>.Focus()</code>.</p>