c# - How can I make that approach's opposite -


how can passing values form 1 directly? receiver form showing on screen , listening passing values sending main form.

i know way delegate , event mine not desired one.

need opposite way. below can code lines. able form2 passes value form1 (main form). need approach's opposite. so, form1 sender form2 receiver, , transmit in real-time while showing on screen.

public partial class form1 : form {     public form1()     {         initializecomponent();     }      private void button1_click(object sender, eventargs e)     {         form2 f = new form2();         f.identityupdated += new form2.identityupdatehandler(form2_buttonclicked);         f.show();     }      private void form2_buttonclicked(object sender, identityupdateeventargs e)     {         textbox1.text = e.firstname;     } }  public partial class form2 : form {     public delegate void identityupdatehandler(object sender, identityupdateeventargs e);     public event identityupdatehandler identityupdated;      public form2()     {         initializecomponent();     }      private void form2_load(object sender, eventargs e)     {         string sfirstname = txtfirstname.text;         identityupdateeventargs args = new identityupdateeventargs(sfirstname);         identityupdated(this, args);     } }  public class identityupdateeventargs : system.eventargs {     private string mfirstname;     public identityupdateeventargs(string sfirstname)     {         this.mfirstname = sfirstname;     }      public string firstname     {            { return mfirstname; }     } } 

try way

public partial class form1 : form {     public delegate void identityupdatehandler(object sender, eventargs e);     public event identityupdatehandler identityupdated;      public form1()     {         initializecomponent();      }      private void button1_click(object sender, eventargs e)     {         form2 form2 = new form2();         form2.show();         identityupdated(this, new eventargs());     } }  public partial class form2 : form {     public form2()     {         initializecomponent();         form1 form1 = (form1)application.openforms["form1"];         form1.identityupdated += form1onidentityupdated;     }      private void form1onidentityupdated(object sender, eventargs eventargs)     {         messagebox.show("received");     } } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -