C#-WinForm 子窗体嵌入主窗体

in with 0 comment

show code

 public static void Into(Form form, Control control)
        {
            control.Controls.Clear();
            if (form == null || form.InvokeRequired)
            {
                form?.Invoke((Action)(() => Into(form, control))); //防止跨线程异常
                return;
            }
            form.TopLevel = false;
            form.Parent = control;
            form.FormBorderStyle = FormBorderStyle.None;
            form.Dock = DockStyle.Fill;
            form.Show();
        }
Responses