Does the designer execute my code?
When the form is displayed in the designer, the designer deserializes the code of your form (Form1.Designer.cs or the first class in Form1.cs) and creates an instance of the base class of your form and deserialize the InitializeComponent and create the controls that you declared in your class and set them properties.
Thus, codes in the Constructor will not be executed. The designer creates an instance of the base class of your form and does not look into the constructor of your form.
An interesting example of how a designer works.
Look at the code below and pay attention to the following problems:
- Where
; s? - Constructor
Form111111 for Form1 ? - What is
NotDefinedFunction() ? - How
int i = "xxxxxxxxxx" ?
Even if you create such a file, the designer will show correctly.
using System using System.Collections.Generic using System.Drawing using System.Windows.Forms namespace Sample { public class Form1:Form { public Form111111() { NotDefinedFunction() InitializeComponent() } public void InitializeComponent() { int i = "xxxxxxxxxx" this.textBox1 = new System.Windows.Forms.TextBox() this.SuspendLayout()
And you will see the form in the designer:

How to add controls dynamically during development?
If you need such functionality, you can create your own dynamic controls in the base class constructor for your form, since the base class constructor will work when the child form is opened in the designer, then it will work during development.
But you should be aware that these controls are inherited and cannot be modified using the constructor of the child form.
So just create Form2:
public Form2() { InitializeComponent(); AddDynamicControls(); } private void AddDynamicControls() { this.Controls.Add( new TextBox() { Name = "TextBox1", Text = "Dynamic", Location = new Point(100, 0) }); }
Create a project, and then change the base class Form1 inherit from Form2 :
public class Form1:Form2
And the result will be:

Is there any other solution?
If you want to create some controls during development, I think you should take a look at T4 Text Templates .
You can use t4 templates to generate code during development. You have probably seen Entity Framework .tt template files. You can add a new Text Template element to your project and place the logic for generating elements during development in your t4 template.