本文介绍了在Winform应用程序中从TabControl隐藏TabPage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Winform的应用程序中有一个TabControl,我必须禁用第二个选项卡,只有在我的第一页上执行某些操作后,才能单击该选项卡.我是通过禁用代码选项卡来实现的
I have a TabControl in Winform s application,I have to disable the second tab, clicking it would be enabled only after some action on my first page.I have achieved this by disabling tab by code
tabControl1.TabPages[1].Enabled = false;
但是我希望该选项卡被隐藏,或者应该禁用该选项卡本身.
But I want that tab to be hidden or clicking the tab itself should be disabled.
推荐答案
尝试一下.它将隐藏并显示TabPage,而不会丢失控件.
Try This. It will hide and show the TabPages without a Control lost.
隐藏TabPage并删除标题:
this.tabPage1.Hide();
this.tabPage3.Hide();
this.tabPage5.Hide();
tabControl1.TabPages.Remove(tabPage1);
tabControl1.TabPages.Remove(tabPage3);
tabControl1.TabPages.Remove(tabPage5);
显示标签页和可见的标题:
tabControl1.TabPages.Insert(0,tabPage1);
tabControl1.TabPages.Insert(2, tabPage3);
tabControl1.TabPages.Insert(4, tabPage5);
this.tabPage1.Show();
this.tabPage3.Show();
this.tabPage5.Show();
tabControl1.SelectedTab = tabPage1;
这篇关于在Winform应用程序中从TabControl隐藏TabPage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!