Hi,
I'm new to C#. I want to add a TabPage dynamically (name depends on data from database). After receiving the data the TabPage tab should be added to the TabControl ( this.Services) but nothing happens. Putting the code somewhere else (without the database dependency) doensn't work either. Even adding items to a ListBox dynamicly doesn't work. Can someone tell me what I have to do to add / create Controls dynamically at runtime?
thanks,
Crystallugia
I'm new to C#. I want to add a TabPage dynamically (name depends on data from database). After receiving the data the TabPage tab should be added to the TabControl ( this.Services) but nothing happens. Putting the code somewhere else (without the database dependency) doensn't work either. Even adding items to a ListBox dynamicly doesn't work. Can someone tell me what I have to do to add / create Controls dynamically at runtime?
Code:
TabPage tab = new System.Windows.Forms.TabPage();
tab.Location = new System.Drawing.Point(4, 22);
tab.Name = reader.GetString(0);
tab.Padding = new System.Windows.Forms.Padding(3);
tab.Size = new System.Drawing.Size(670, 335);
tab.TabIndex = 3;// this.Services.Controls.Count + 1;
tab.Text = reader.GetString(0);
tab.UseVisualStyleBackColor = true;
this.Services.Controls.Add(tab);
Crystallugia
Comment