TabPageControl作为UserControl:增加了字幕和按钮

发布于 2024-12-11 21:45:04 字数 1304 浏览 0 评论 0原文

在 C# 中,我创建了从 TabPage 继承的 TabControl:

public partial class TabPageControl : TabPage
{
        public AutoScaleMode AutoScaleMode = AutoScaleMode.Inherit;

        private TabPagePanelControl tabControlPanel = new TabPagePanelControl();

        public TabPageControl()
        {
            InitializeComponent();

            tabControlPanel.Dock = DockStyle.Fill;
            this.Controls.Add(tabControlPanel);
        }
    ...
}

此 tabPage 被添加到 TabControl。 TabControl 也被创建为 UserControl:

public partial class TabControlControl : TabControl
    {
        public delegate void OnHeaderCloseDelegate(object sender, CloseEventArgs e);
        public event OnHeaderCloseDelegate OnClose;

    public TabControlControl()
    {
        InitializeComponent();
        //SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);
        this.TabStop = false;
        this.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
        this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.ItemSize = new System.Drawing.Size(230, 24);
    }
...
}

问题在于该控件的显示。在TabControl中,以编程方式将其添加到表单后,增加了按钮和字幕。我想要正常尺寸的它们。

谢谢

In C# I have created TabControl which inherits from TabPage:

public partial class TabPageControl : TabPage
{
        public AutoScaleMode AutoScaleMode = AutoScaleMode.Inherit;

        private TabPagePanelControl tabControlPanel = new TabPagePanelControl();

        public TabPageControl()
        {
            InitializeComponent();

            tabControlPanel.Dock = DockStyle.Fill;
            this.Controls.Add(tabControlPanel);
        }
    ...
}

This tabPage is added to TabControl. TabControl is created as UserControl too:

public partial class TabControlControl : TabControl
    {
        public delegate void OnHeaderCloseDelegate(object sender, CloseEventArgs e);
        public event OnHeaderCloseDelegate OnClose;

    public TabControlControl()
    {
        InitializeComponent();
        //SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);
        this.TabStop = false;
        this.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
        this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.ItemSize = new System.Drawing.Size(230, 24);
    }
...
}

The problem is with the display this controls. In TabControl, after programmatically added it to form, buttons and subtitles are increased. I would like to have them in normal size.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦回梦里 2024-12-18 21:45:04

好吧,问题可能是您以编程方式设置 TabControlControl.ItemSize ,它恰好是“获取或设置控件选项卡的大小"

Well, may be the problem is that you programmatically set TabControlControl.ItemSize which is exactly "Gets or sets the size of the control's tabs"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文