c# - Dockpanel Suite and passing data across multiple forms -


hi couldn't find referenced looking for. have seen many examples on sites of passing data between 2 forms such as

how can pass values 1 form another? using controls of 1 form another how access controls on inherited form?

on top of several blogs , hours of reading , not getting it.

so here act trying accomplish using dockpanel suite


main form parentform has form form1 docked inside there. cannot removed or reloaded constant(so should same instance assume) has textboxfrm1box. parentform has menu bar button button1 open third form form2 has textbox frm2box. able click button1(from parentform) have open form2 , pass whatever in frm1box frm2box.


so reading seemed setting properties recommended did , works great if button click on form1 open form2 , pass data cant seem figure out when adding form. not full code happy post actual code if needed didnt save space.

//parent form public partial class parentform : form  public static form1 form1 = new form1();  public void showform1()     {         form1 = new form1();         form1.show(dockpanel1, dockstate.dockleft);     } private void parentform_load(object sender, eventargs e)     {         showform1();     } private void button1_click(object sender, eventargs e)     {         form2 form2 = new form2();         form2.custnamecb = form1.custname;         form2.show();     }    //form1 public partial class form1 : dockcontent    { private string _custname;  public form2()     {         initializecomponent();      } public string custname     {                 {             return _custname;         }         set         {             _custname = value;             frm1box.text = _custname;         }      }   //form2 public partial class form2 : form    { private string _custnamecb;  public form2()     {         initializecomponent();      } public string custnamecb     {                 {             return _custnamecb;         }         set         {             _custnamecb = value;             frm2box.text = _custnamecb;         }      } 

i think missing concept altogether couldn't find "good" example of in searches or @ least 1 follow. new programming , c# in particular please forgive inexperience. if has better way of doing please let me know. have considered using sql store data. prefer not use file based storage if possible. worth noting once find proper method of doing need scale-able because when implement 5 different buttons on parentform opening 5 different form's still pulling data same form1 yet form1 have around 10 textboxes of data pull.

thanks in advance replies.

you're close. in properties, "setter" displaying passed value in textbox, how "getter" retrieving value textbox? returning value stored in private variable. form1, setting private variable "_custname" somehow (now shown) thru code (like thru textchanged() event maybe)?

if not, change property to:

public string custname {         {         return frm1box.text;     }     set     {         frm1box.text = value;     } } 

this return value in textbox , second form...


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -