David Acero
David Acero

Reputation: 364

Winforms: panel doesn't update/refresh content when scrolling

I'm creating a windows forms with one groupbox and two panels:

enter image description here

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

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

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.

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

This is how it looks in run-time:

enter image description here

Upvotes: 1

Views: 1286

Answers (1)

David Acero
David Acero

Reputation: 364

I ended up leaving the groupbox inside the panel, (the opposite of what I was doing before) and added the controls to the groupbox instead of the panel. Then I set in the groupbox AutoSize = true and in the panel AutoScroll = true.

Now it works perfect!

enter image description here

Upvotes: 1

Related Questions