using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;namespace WindowsApplication249 { public partial class Form1 : Form { public Form1() { InitializeComponent(); Panel P = new Panel(); P.Dock = DockStyle.Left; P.Parent = this; P.Width = 50;
this.IsMdiContainer = true;
Form F = new Form(); F.MdiParent = this; F.Show(); F.Dock = DockStyle.Fill; } } }
新建自定义控件 ControlA,ControlB
窗体中 Controls.Add(new ControlA())
切换就是把先前那个ControlA移掉
再Controls.Add(new ControlB())
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication249
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); Panel P = new Panel();
P.Dock = DockStyle.Left;
P.Parent = this;
P.Width = 50;
this.IsMdiContainer = true;
Form F = new Form();
F.MdiParent = this;
F.Show();
F.Dock = DockStyle.Fill;
}
}
}