Search code examples
c#winformsinheritancetabpage

TabPageControl as UserControl: subtitles and buttons are increased


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


Solution

  • 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"