Sending a String From One Form To another Form C# -
this question has answer here:
- passing value 1 form (c#) 1 answer
i've been trying send string 1 form named mainform other form unlockform.
the references i've found sending values things textboxes. want send string.
this done in 2 ways. if trying pass string owner form child form, can in parameter, so:
class owner : form {    private child child;    public owner()    {        child = new child("value pass");    } } class child : form {      public child(string value)     {         //do value     } } if want pass child owner, this:
class owner : form {    public owner()    {        child = new child();        child.showdialog();        string childvalue = child.value;    } } class child : form {     public string value{get;set;}     public child()     {      }      protected override void onshown(eventargs e)     {         base.onshown(e);         value = "value set";         this.close();     } } note i'm using "child.showdialog()" make sure child form closed before value returns. isn't necessary, safer.
Comments
Post a Comment