Visual studio provide the best features to design the form. By the designer window, you can add the controls from the toolBox. After added the items, you can set the properties by the property window. Same this things, you can do this by the code window. Follow some steps to add controls dynamically.
Step-1 : Open Code window that is form1.cs file, create a object for controls like
TextBox t1 = new TextBox();
Step-2 : Associate properties of the TextBox class with the current object like
t1.Name = "Text1";
t1.Width = 300;
t1.Text = " Dynamically added Control";
t1.Location = new Point(10, 10);
Here Point is a class, in which you have to define the coordinates of x-axis and y-axis, where you want to add the TextBox.
Step-1 : Open Code window that is form1.cs file, create a object for controls like
TextBox t1 = new TextBox();
Step-2 : Associate properties of the TextBox class with the current object like
t1.Name = "Text1";
t1.Width = 300;
t1.Text = " Dynamically added Control";
t1.Location = new Point(10, 10);
Here Point is a class, in which you have to define the coordinates of x-axis and y-axis, where you want to add the TextBox.
Step-3 : Add this instance in the form by following line of code.
this.Controls.Add(t1);
Now code Generate the following output:
this.Controls.Add(t1);
Now code Generate the following output: