C#:Use Form as Subform

1225 ワード

static class SubFormExtensions
{
    internal static bool AttachTo(this Form subForm, Panel panel)
    {
        if (panel == null || subForm == null) return false;
        subForm.FormBorderStyle = FormBorderStyle.None;
        subForm.TopLevel = false;
        subForm.ShowInTaskbar = false;
        subForm.Show();
        subForm.Dock = DockStyle.Fill;
        panel.Controls.Add(subForm);
    }
}