TabPageControl as UserControl:增加了字幕和按钮

时间:2011-10-25 07:39:11

标签: c# winforms inheritance tabpage

在C#中,我创建了TabControl,它继承自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);
        }
    ...
}

此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中,在以编程方式将其添加到表单后,按钮和字幕会增加。我想让它们正常。

由于

1 个答案:

答案 0 :(得分:0)

好吧,可能问题是你以编程方式设置TabControlControl.ItemSize,这正好是“Gets or sets the size of the control's tabs