title: Smooth Expanding and Collapsing Animation for WinForms
body: <p>Im trying to get a smooth expanding and collapsing animation for my form. My current animation is really jittery and non consistent. Heres a Gif of the <a href="https://i.gyazo.com/e18bda26e5b4679b756423cb71a1b8cd.gif" rel="nofollow">Animation</a>. Is there another way to do this that doesnt freeze the form?</p>
  
  <pre><code>private void ShowHideToggle_CheckStateChanged(object sender, EventArgs e)
      {
          if (ShowHideToggle.Checked) //checked = expand form
          {
              ShowHideToggle.Text = "&lt;";
              while (Width &lt; originalWidth)
              {
                  Width++;
                  Application.DoEvents();
              }
          }
          else
          {
              ShowHideToggle.Text = "&gt;";
              while(Width &gt; 24)
              {
                  Width--;
                  Application.DoEvents();
              }
          }
      }
  </code></pre>