forms - c# add label from form2 -


form2 code:

public void button2_click(object sender, eventargs e)         {              form1 form1form = new form1();             label asd = new label();             asd.text = "asdasasdasdasd";             form1form.controls.add(asd);              form2 form2form = new form2();              form2form.close();  } 

i want add new label , button on form1 form2

how made ?

thanks

if want access form1form form2form must have public reference form1form. declare property in form1form below:

public static form1form instance { get; private set; } 

then set instance in load event of form1form:

private void form1form_load(object sender, eventargs e) {    instance = this; } 

in form2form:

public void button2_click(object sender, eventargs e) {     label asd = new label();     asd.text = "asdasasdasdasd";     form1form.instance.controls.add(asd); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -