Reputation: 48
I am creating a tool that inherits from the TabControl. This is meant to function like TabControl, but with a few added features. But, everytime I drag TabControl or my tool onto the form, 2 TabPages are immediately created. I do not want these two tabpages created in designer, how can I prevent these two tabpages from being created?
Upvotes: 0
Views: 95
Reputation: 54463
This is a good question; unfortunately there seems to be no good answer.
The two pages are created by default for any TabControl
, not just your subclass.
It is not in your code nor in the MSDN sources.
From Hans' comment I assume that there is a 'designer template' that a form (or a top level control class, e.g. a UserControl
) uses to add extra initialization code in the Form's InitializeComponent
code. We should not mess with this code!
Here, in the Form1.Designer.cs
code the tabpages are created, with their stupid names, as class-wide controls and added to the tab.
The simplest solution is to remove the pages in the designer manually.
The only other workaround I can think of is to clear the pages e.g. in the form's constructor:
public Form1()
{
InitializeComponent();
customTab1.TabPages.Clear();
}
Note: The default TabPages
are not added when you create and add the TabControl
in code.
Upvotes: 1