Viva
Viva

Reputation: 2075

how to auto adjust controls when their size changes c#

I have on winform an usercontrol that can be multiple created dynamically at runtime. I have two ways to see them: in maximal mode and minimal mode. The idea is that ,when they are minimal,some objects from usercontrol are hidden. I want,if I switch to maximal mode,the usercontrols to be automatically adjusted .How can I do that?I started with the idea to compute their width and height ,but I don't know how to create the new points. My pictures below show better:

this is in minimal mode:

enter image description here

how they look when I change it to maximal mode: enter image description here

how I would like to be usercontrols: enter image description here

Upvotes: 2

Views: 485

Answers (2)

Tigran
Tigran

Reputation: 62248

You should use Anchor property of controls, and can set it even from Property Window of VisualStudio in design time.

For more: How to: Anchor Controls on Windows Forms

another option, that by the way can be used in conjuction with Anchor is use of TableLayoutPanel

Upvotes: 1

Related Questions