Button btn = new Button(); btn.Text = "Click me!"; btn.Width = 100; btn.Height = 30; btn.Top = 50; btn.Left = 50; this.Controls.Add(btn); //adding button to parent control
TextBox txt = new TextBox(); txt.Name = "textBox1"; txt.Width = 150; txt.Height = 30; txt.Top = 50; txt.Left = 10; Panel panelCtrl = new Panel(); panelCtrl.Controls.Add(txt); //adding textbox to parent controlThese examples demonstrate the use of the CreateControl method to create and add controls to a parent control. The package used in this case is the System.Windows.Forms package.