Reputation: 2075
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:
how they look when I change it to maximal mode:
how I would like to be usercontrols:
Upvotes: 2
Views: 485
Reputation: 9074
Use Dock
or Anchor
property for this.
Eg. groupBox1.Dock = DockStyle.Top;
MSDN For Dock:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock.aspx
MSDN For Anchor:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.anchor.aspx
Article With Exaple:
Upvotes: 1
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