title: FlowLayoutPanel scrollbar doesn't disapear properly sometimes
body: <p>I am facing a really strange issue and after googling and searching in StackOverflow i absolutly have no clue how to fix that because it only happens sometimes.</p>
  
  <p>My Problem:</p>
  
  <p>I have a flowLayoutPanel (flp) and only a the vertical scrollbar if controls inside my flp doesnt fit it's size. I don't use a horizontal scrollbar.
  Code for that:</p>
  
  <pre><code>private void setFlowcontrolScrollbar(flowLayoutPanel fc)
  {
      int height = 0;
  
      foreach (FilePanel fp in fc.Controls)
      {
          height += fp.Height;
      }
  
      if (height &gt; fc.Height)
      {
  
          fc.VerticalScroll.Visible = true;
          fc.VerticalScroll.Enabled = true;
      }
      else
      {
          fc.VerticalScroll.Visible = false;
          fc.VerticalScroll.Enabled = false;
      }
  
      fc.HorizontalScroll.Visible = false;
      fc.HorizontalScroll.Enabled = false;
  }
  </code></pre>
  
  <p>This method is called after the flp was resized or new items were added to it. Controls in my flp are resized only in horizontal direction.</p>
  
  <p>Now this works fine, i can scroll if there are to many controls in my flp. But let's say i have lot's of controls in my flp (=> vertical scrollbar enabled,visible) and now i delete some controls so i would not need a scrollbar anymore. Functional everything works fine, i cant scroll or click on a scrollbar. But sometimes there is a visual bug. The scrollbar doesn't disapear and i can do strange things like in this picture:</p>
  
  <p><a href="https://i.stack.imgur.com/5ZW3y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ZW3y.png" alt="enter image description here"></a></p>
  
  <p>If i also call void setFlowcontrolScrollbar after removing a control this happens almost all the time when i remove a control and scrollbar is not needed any more:</p>
  
  <p><a href="https://i.stack.imgur.com/mjxro.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mjxro.png" alt="enter image description here"></a></p>
  
  <p>In both pictures i resized my form a bit to the right so you can see how my controls overlap with the scrollbar. How do i fix that? Is there a better way to only activate vertical scroll? </p>
  
  <p>IMPORTANT EDIT:</p>
  
  <p>Bug only occurs if i use drag'n'drop to remove lines (controls) from my flp and only if i touched/hovered over the scrollbar while draging. If i drag it out on the left side and drop it somewhere else the scrollbar disappears correct.</p>
  
  <p>Note: Found a better solution to get rid of horizontal scroll.</p>
  
  <pre><code>panel.HorizontalScroll.Maximum = 0;
  panel.AutoScroll = false;
  panel.VerticalScroll.Visible = false;
  panel.AutoScroll = true;
  </code></pre>
  
  <p>(Source: <a href="https://stackoverflow.com/questions/5489273/how-do-i-disable-the-horizontal-scrollbar-in-a-panel">How do I disable the horizontal scrollbar in a Panel</a> , answer from "Kbv Subrahmanyam")</p>