E
Earl
I'm trying to dynamically position a combo and label on a tabcontrol. The
old Infragistics tabcontrol made this easy, but I'm trying to do it with
VS2005 common controls. Well, I cannot dynamically add a control to a
tabcontrol directly -- as the message says, "Cannot add 'ComboBox' to
TabControl. Only TabPages can be directly added to TabControls."
Sooooo .. what I am doing instead is to Add and Remove the combo and label
to each of the 8 tabpages as the tab is selected. This I *can* do, but I'm
not sure if this is the correct or best approach -- just one that works.
What I'm doing is to only create the combo and label in code, not in the
designer. I instantiate the control in the InitializeComponent then as each
tabpage selection is made, Add the combo to the tabpage and ALSO Remove the
combo from ALL the other tabpages. Any thoughts from anyone who has been
through this? Is there a better way?
switch (tabControl1.SelectedTab.Name.ToString())
{
case "tabW":
this.tabW.Controls.Add(this.cmbWidgets);
this.tabC.Controls.Remove(this.cmbWidgets);
this.tabS.Controls.Remove(this.cmbWidgets);
....
}
old Infragistics tabcontrol made this easy, but I'm trying to do it with
VS2005 common controls. Well, I cannot dynamically add a control to a
tabcontrol directly -- as the message says, "Cannot add 'ComboBox' to
TabControl. Only TabPages can be directly added to TabControls."
Sooooo .. what I am doing instead is to Add and Remove the combo and label
to each of the 8 tabpages as the tab is selected. This I *can* do, but I'm
not sure if this is the correct or best approach -- just one that works.
What I'm doing is to only create the combo and label in code, not in the
designer. I instantiate the control in the InitializeComponent then as each
tabpage selection is made, Add the combo to the tabpage and ALSO Remove the
combo from ALL the other tabpages. Any thoughts from anyone who has been
through this? Is there a better way?
switch (tabControl1.SelectedTab.Name.ToString())
{
case "tabW":
this.tabW.Controls.Add(this.cmbWidgets);
this.tabC.Controls.Remove(this.cmbWidgets);
this.tabS.Controls.Remove(this.cmbWidgets);
....
}