How to make WinForms UserControl fill the size of its container

.net, c#, mdi, multipage, winforms

Solution

Try setting the `Dock` property to `Fill`:

private void ManageUsersControl_Load(object sender, EventArgs e)
{
        this.Dock = DockStyle.Fill;
}

I would also set `AutoSize` to the default, I believe is `False`. See how that works ...

Problem

I am trying to create a multilayout main screen application. I have some buttons at the top that link to the main section of the application (e.g. management window for each entity in the Model) Clicking any of these button displays the associated UserControl in a Panel. The Panel holds the UserControls that in turn holds the UI. The WinForms UserControl does not have the `Anchor` or `Dock` property. I have tried setting property of UserControl ``` AutoSize=True ``` And ``` private void ManageUsersControl_Load(object sender, EventArgs e) { this.Width = this.Parent.Width; this.Height = this.Parent.Height; } ``` But these did not work. Note: I load this control dynamically at runtime

Original source