Пример #1
0
 private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tabControl.SelectedIndex == 0)//也可以判断tabControl1.SelectedTab.Text的值
     {
         //执行相应的操作
         tmpTree = zongTreeView;
         splitContainer1.Panel1.Controls.Remove(dataGridView);
         splitContainer1.Panel2.Controls.Remove(richTextBox);
         // Console.WriteLine(3);
     }
     else if (tabControl.SelectedIndex == 1)
     {
         //执行相应的操作
         tmpTree = designTreeView;
         DesignControls designControls = new DesignControls(splitContainer1);
         dataGridView            = designControls.dataGridView1;
         richTextBox             = designControls.richTextBox1;
         dataGridView.DataSource = newdt;
         //PID.ID不可编辑,隐藏最后一列
         dataGridView.Columns[0].ReadOnly = true;
         dataGridView.Columns[1].ReadOnly = true;
         dataGridView.Columns[3].Visible  = false;
     }
     else if (tabControl.SelectedIndex == 2)
     {
         tmpTree = testTreeView;
     }
     else if (tabControl.SelectedIndex == 3)
     {
         tmpTree = ylTreeView;
     }
     else if (tabControl.SelectedIndex == 4)
     {
         tmpTree = reportTreeView;
     }
 }
Пример #2
0
        private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl.SelectedIndex == 0)//也可以判断tabControl1.SelectedTab.Text的值
            {
                //执行相应的操作
                flag    = 0;
                tmpTree = zongTreeView;
                this.Controls.Remove(splitContainer1);
                //designControls.Dispose();释放了不能重新加载控件,关闭之后用
                // splitContainer1.Panel1.Controls.Remove(dataGridView);
                //splitContainer1.Panel2.Controls.Remove(richTextBox);
                // Console.WriteLine(3);
            }
            else if (tabControl.SelectedIndex == 1)
            {
                //执行相应的操作
                flag    = 1;
                tmpTree = designTreeView;

                CreatesplitContainer();
                designControls = new DesignControls(splitContainer1);
                dataGridView   = designControls.dataGridView1;

                richTextBox = designControls.richTextBox1;

                newdt = new DataTable();
                DataColumn[] cols = { new DataColumn("PId",  typeof(uint)),
                                      new DataColumn("Id",   typeof(uint)),
                                      new DataColumn("Name", typeof(string)) };
                newdt.Columns.AddRange(cols);
                //newdt.Columns.Add("PId", typeof(uint));
                //newdt.Columns.Add("Id", typeof(uint));
                //newdt.Columns.Add("Name", typeof(string));
                dataGridView.DataSource = newdt;
                //调整列宽填充控件
                dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                //dataGridView.DataMember设计列表的名称
                //包含行标题的列
                dataGridView.RowHeadersVisible = true;
                //PID.ID不可编辑,隐藏最后一列
                dataGridView.Columns[0].ReadOnly = true;
                dataGridView.Columns[1].ReadOnly = true;
            }
            else if (tabControl.SelectedIndex == 2)
            {
                flag    = 2;
                tmpTree = testTreeView;
                this.Controls.Remove(splitContainer1);
            }
            else if (tabControl.SelectedIndex == 3)
            {
                flag    = 3;
                tmpTree = ylTreeView;
                this.Controls.Remove(splitContainer1);
            }
            else if (tabControl.SelectedIndex == 4)
            {
                flag    = 4;
                tmpTree = reportTreeView;
                this.Controls.Remove(splitContainer1);
            }
        }