add tabcontrol at runtime

May 2 2005 7:09 AM
i am trying to add a tabcontrol at run time and to this tab control i am trying to add tabpages,further to these tab pages i have to add checkboxes,labels and textboxes(all at run time).the tab control and tab page are added but the checkboxex,labels tc are not visible. this is the code:- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace deleteit1 { public class Form2 : System.Windows.Forms.Form { private System.ComponentModel.Container components = null; TabControl tb = null; TabPage tbpage = null; Panel panel = null; public Form2() { InitializeComponent(); } [STAThread] static void Main() { Application.Run(new Form2()); } protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { // // Form2 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(800, 486); this.Name = "Form2"; this.Text = "Form2"; this.Load += new System.EventHandler(this.Form2_Load); } #endregion private void Form2_Load(object sender, System.EventArgs e) { addtabcontrol(); } public void addtabcontrol() { tb = new TabControl(); tb.Location = new System.Drawing.Point(212, 168); this.Controls.Add(tb); addtabpages(); } public void addtabpages() { for(int i =0;i<=1;i++) { panel = new Panel(); tbpage = new TabPage(); tbpage.Controls.Add(initializecontrols(panel)); tb.Controls.Add(tbpage); } } public Panel initializecontrols(Panel panel) { Label lb = new Label(); TextBox tb1 = new TextBox(); CheckBox chkbox = new CheckBox(); chkbox.Visible = true; chkbox.Top = 250; chkbox.Left = 200;; chkbox.Size = new System.Drawing.Size(72, 24); chkbox.Text = "Active"; // tbpage.Controls.Add(lb); // tbpage.Controls.Add(tb1); // tbpage.Controls.Add(chkbox); panel.Controls.Add(chkbox); return panel; } } } the application is window based kindly help