I am adding this tabcontrol to the main form. It seems to work because all code after this is working and subsequent controls are being added fine.
System.Windows.Forms.TabControl Control_TabControl = new System.Windows.Forms.TabControl();
Control_TabControl.Name = "tabControl";
Control_TabControl.Location = new System.Drawing.Point(0, 24);
Control_TabControl.Size = new System.Drawing.Size(1630, 415);
Control_TabControl.Dock = DockStyle.Fill;
Control_TabControl.Appearance = TabAppearance.Normal;
this.Controls.Add(Control_TabControl);
for (int i = 1; i <= Count; i++)
{
TabPage tabPage = new TabPage
{
Name = "Tab" + i,
Text = "Tab" + i
};
Control_TabControl.TabPages.Add(tabPage);
}
But there is a problem, on the form I cannot see the actual tabs. I can see what appears to be the first tab contents, but not the actual expected "Tab1" or "Tab2" control to click.
Inspecting the code during runtime shows that there is indeed 2 tabs as expected and all looks just fine, but its not...
The main form does not have any other controls added in design mode except for a menu bar and status bar.
What could cause this behavior?
When I removed this command:
Control_TabControl.Dock = DockStyle.Fill;
it was properly showing up. It turns out the Fill command was filling the control into the whole main form UNDERNEATH the menu too.
So, in my case, for the code it is used in, simply not using Fill and specifying the size properly was good enough.