I have a class in the same file as the Form1 : Form class (directly proceeding) and would like to create a new control (label thisObj = new label();) from within the class. I tried to use the following code:
Form1 form = new Form1();
label thisObj = new label();
thisObj.Name = "One";
form.Controls.Add(thisObj);
However, when I do this, the form window doesn’t load when starting the debugging.
EDIT: The line “Form1 form = new Form1()” causes the form not to load.
I worked around this by sending an instance of the Form through the constructor of the class.