WinForm TabControl:如何动态隐藏/显示选项卡标题?
我想让我的 tabControl 更智能一点,以节省一些屏幕空间:如果只有一个选项卡,则不显示选项卡标题;如果有两个或多个选项卡,则显示选项卡标题。
我知道您可以按照 如何创建没有选项卡标题的 TabControl?。这种方法的问题是,一旦隐藏,我就无法再次显示选项卡标题。或者我错过了什么?
I want to make my tabControl a little smarter to save some screen real estate: Don't show tab header if there is only one tab and show tab headers if there are two or more tabs.
I know that you can hide the tab header completely as suggested at How do I create a TabControl with no tab headers?. The problem with this approach is that, once hidden, I cannot show the tab header again. Or did I miss something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
感谢实际上来的人同意这个想法:
Crediting the guy that actually came up with the idea:
坟墓挖了一下,但我知道另一种解决方案。我不知道它来自哪里,但它是:
在表单加载中:(VB.NET)
其中
TabControl1
是选项卡控件的名称,TabPage1
是名称该控件中第一个选项卡页的位置。如果您想让它作为例程使用,那么您可以这样做:
就是这么简单。这样做的好处是,标题在运行时不会显示,但在设计时可见。
Grave digging a bit but I know of another solution. I have no idea where it came from but here it is:
In form load: (VB.NET)
Where
TabControl1
is the name of your tab control andTabPage1
is the name of the first tab page in that control.If you wanted to make it usable as a routine then you could do something like this:
It is that easy. What is nice about this is that the headers are not shown at runtime but they are visible at design time.
扩展汉斯的答案:
我希望 TabControl 也能够在设计时隐藏选项卡,但是出现了一个问题,一旦隐藏选项卡,就无法选择 TabControl 再次打开它们,所以我创建了一个自定义 TabPage,它能够控制此属性
To expand on Hans's answer:
I wanted to have the TabControl able to hide tabs in design time too, but then there was a problem, that once you hide the tabs, there is no way to select the TabControl to turn them on again, so i created a custom TabPage, that is able to control this property