I have a preexisting UltraTabControl. I want to dynamically add tabs to it and have it initialize to a custom class that inherits from UserControl. Here is how I do it.
M3Control newControl = new CustomUserControl();
newControl.BackColor = System.Drawing.SystemColors.ControlLight;
newControl.Location = new System.Drawing.Point(0, 0);
newControl.Name = "newControl1";
newControl.TabIndex = 0;
newControl.Dock = System.Windows.Forms.DockStyle.Fill;
UltraTab tabToAdd = new UltraTab();
utpc.Location = new System.Drawing.Point(-10000, -10000);
utpc.Controls.Add(newControl);
tabToAdd.TabPage = utpc;
appearance1.BackColor = System.Drawing.Color.Orange;
appearance1.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
m3tc.ActiveTabAppearance = appearance1;
m3tc.Add(tabToAdd);
When I run this I get a blank screen on the newly added tab instead of the "newControl" instance (which has some controls on it such as label, textboxes, etc). What am I doing wrong?
I see two issues with the code:
Thanks for the reply, I figured out the problem. The "Add" method returns a UltraTab instance which is the actual instance that gets added. Updating that instance has given me the desired results.
Hi,
I have come across the same issue, and would like to know what you have mentioned as "Updating that instance". Can you please provide me with the sample coding
Thanks.
nw
This is what worked for me
var
ultraTab = ultraTabControl1.Tabs.Add("MyTab1", "My Tab");
ultraTab.TabPage.Controls.Add(new MyCustomControl());