Button btn = new Button(); btn.Text = "Click me!"; panel1.Controls.Add(btn);
TextBox textBox = new TextBox(); textBox.Name = "myTextBox"; panel1.Controls.Add(textBox);This code will create a new TextBox control, give it a name of "myTextBox", and add it to the Controls collection of a Panel control named panel1. These examples use the standard .NET library for Windows Forms applications.