日期:2014-05-17  浏览次数:20827 次

诚心求教,在TreeView中只new一次FORM如何实现
本帖最后由 u010466340 于 2013-07-06 16:43:34 编辑
  public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            switch (e.Node.Name)
            {
                case "Node1":
                    Form1 F1 = new Form1();
                    F1.TopLevel = false;
                    F1.FormBorderStyle = FormBorderStyle.None;
                    F1.WindowState = FormWindowState.Maximized;
                    panel显示.Controls.Add(F1);
                    F1.Show();
                    break;

                case "Node2":
                    Form2 F2 = new Form2();
                    F2.TopLevel = false;
                    F2.FormBorderStyle = FormBorderStyle.None;
                    F2.WindowState = FormWindowState.Maximized;
                    panel显示.Controls.Add(F2);