当前位置:编程学习 > C#/ASP.NET >>

如何在程序中删除tabpage

如何在程序中删除tabpage --------------------编程问答-------------------- 隐藏Tab.TabPages[1].Parent = null;
Tab.TabPages[1].Parent = Tab;

TabPage tp = tabControl1.TabPages[0];
tabControl1.TabPages.Remove(tp);//隐藏(删除)
tabControl1.TabPages.Insert(0, tp);
--------------------编程问答--------------------
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex != -1)
            {
                switch (comboBox1.SelectedItem.ToString())
                {
                    case "tabPage1":
                        tabPage2.Parent = null;
                        tabPage3.Parent = null;
                        tabPage4.Parent = null;
                        tabPage1.Parent = this.tabControl1;
                        break;
                    case "tabPage2":
                        tabPage1.Parent = null;
                        tabPage3.Parent = null;
                        tabPage4.Parent = null;
                        tabPage2.Parent = this.tabControl1;
                        break;
                    case "tabPage3":
                        tabPage1.Parent = null;
                        tabPage2.Parent = null;
                        tabPage4.Parent = null;
                        tabPage3.Parent = this.tabControl1;
                        break;
                    case "tabPage4":
                        tabPage1.Parent = null;
                        tabPage2.Parent = null;
                        tabPage3.Parent = null;
                        tabPage4.Parent = this.tabControl1;
                        break;
                }
            }
        }


上面的代码演示了,如果用下拉列表的选择,来显示某个tabpage,同时删除其他的tabpage
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,