Reputation: 364
I'm creating a windows forms with one groupbox and two panels:
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:
Upvotes: 1
Views: 1286
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!
Upvotes: 1