Winforms: panel doesn't update/refresh content when scrolling
<p>I'm creating a windows forms with one groupbox and two panels:</p>

<p><a href="https://i.stack.imgur.com/oscbT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oscbT.png" alt="enter image description here"></a></p>

<p>In the first panel, I'm going to add and remove dynamically controls with the buttons add and remove from the second panel.</p>

<p>In the first panel, I set <code>AutoScroll = true</code>, so that when it has a lot of controls the user can edit them without changing the size of the dialog.</p>

<p>The problem that I have is that the first panel doesn't refresh or update its contents, when I add or remove controls with the buttons.</p>

<p>I tried to invalidate the panel when the events of the buttons are triggered, but it doesn't work.</p>

<p>This is how it looks in run-time:</p>

<p><a href="https://i.stack.imgur.com/pQKb0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pQKb0.png" alt="enter image description here"></a></p>