Form integrated in groupBox

0

I have a main form divided into two groupboxes, the first groupbox is where the tabs are and on each tab a different keypad the second groupbox (gbContainer) is empty, and what I want to do is that when one of the buttons is clicked, a form (frmHijo) "integrated" in that groupbox is displayed, that is, that the child occupies the gbContainer space and always grow / decrease depending on the main form.

Thank you.

    
asked by U. Busto 17.01.2017 в 12:12
source

1 answer

1

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);
    
answered by 17.01.2017 / 12:18
source