So that the controls included in a container adapt to the size of the father you have to use two properties of them:
-
Dock: This property allows the control to paste to one side of the parent control. Very useful for, for example, creating stacked controls in vertical or horizontal.
-
Anchor: This property allows you to set the distance between the ends of the child control and the edges of the parent control. In this case the control can be in any position. If the parent has modified its size, the child control will try to maintain the relationship set by this property by modifying its own size.
As for what you mention about adding a form to a user control ... it is not usually recommended. As far as I remember to add a form to a user control it is necessary to modify the property TopLevelProperty
of the form. I think the most logical thing would be to replace the form with a UserControl
.
An example using a form could be:
Form frm = new ...;
frm.TopLevel = false;
control.Controls.Add(frm);