gpt4 book ai didi

winforms - WinForm TabControl : How to hide/show tab headers dynamically?

转载 作者:行者123 更新时间:2023-12-02 19:17:20 29 4
gpt4 key购买 nike

我想让我的 tabControl 更智能一点,以节省一些屏幕空间:如果只有一个选项卡,则不显示选项卡标题;如果有两个或更多选项卡,则显示选项卡标题。

我知道您可以按照How do I create a TabControl with no tab headers?中的建议完全隐藏选项卡标题。 。这种方法的问题是,一旦隐藏,我就无法再次显示选项卡标题。还是我错过了什么?

最佳答案

归功于这个人,实际上 came up with the idea :

using System;
using System.ComponentModel;
using System.Windows.Forms;

public class WizardPages : TabControl {
private bool tabsVisible;

[DefaultValue(false)]
public bool TabsVisible {
get { return tabsVisible; }
set {
if (tabsVisible == value) return;
tabsVisible = value;
RecreateHandle();
}
}

protected override void WndProc(ref Message m) {
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328) {
if (!tabsVisible && !DesignMode) {
m.Result = (IntPtr)1;
return;
}
}
base.WndProc(ref m);
}
}

关于winforms - WinForm TabControl : How to hide/show tab headers dynamically?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7957484/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com