
Originally Posted by
HairyMike
You could create a custom tabpage control (which inherits tabpage) and set the colour as it is initialised
I don't see how that is any different from just setting the BackColor after I create the TabPage. I still don't know what color to set it to, since it can be different for every type of Windows, every Theme etc...
I also saw this behaviour in all of my custom tabcontrols (I made quite a few); they all had a gray background. I just set it to White manually though because I was using Vista back then, I didn't even think about users on XP who might find a white background strange (oops!).

Originally Posted by
HairyMike
or you could have one created at designtime and made invisible... then create new instance at runtime.
I just tried this but I didn't get it to work correctly, can you explain this further?
I added just a blank TabPage (TabPage1) and changed the code to this:
vb.net Code:
Dim cList As List(Of objDataInfo)
Public Sub New(ByVal n As Integer)
InitializeComponent()
cList = New List(Of objDataInfo)
'Create tabpages on the fly
For i As Integer = 1 To n
Dim t As TabPage = TabPage1
t.Text = "Objective " & i
Dim c As objDataInfo = New objDataInfo(i)
t.Controls.Add(c)
c.Dock = DockStyle.Fill
c.Visible = True
tab.TabPages.Add(t)
Next
tab.TabPages.Remove(TabPage1)
End Sub
The BackColor is now correct, but I just see a blank "TabPage 5" (n = 5) 5 times. There is no sign of my control, and only TabPage5 appears (5 times...)
Not very surprising actually since I'm just copying the same tabpage into the TabControl 5 times..?
I probably didn't understand correctly.