pass a value from one form to another

后端 未结 7 1172
Happy的楠姐
Happy的楠姐 2020-11-27 21:10

I have two forms, and I need pass a value from form1.textbox1 to form2.variable

Form1:

string Ed = \"\", En = \"\"; 

public string En1
{
    get { r         


        
7条回答
  •  失恋的感觉
    2020-11-27 21:55

    Always keep a copy of the information of form2 in form1, this is:

    When the user clicks save on form2 the information go in the local variables of form2 and then form2 runs an Event (telling form1 that its information must be saved). In form1 you handle this event and tell form1 that whenever this event is run from1 must copy the information of form2 into itself.

    On the other hand when ever you are opening form2 again you should first give the information back to it and then execute the show() method. After this you should handle the shown() event of form2 in the way that whenever it is shown, first form2 must put the information it has to the related textboxes, etc ... .

提交回复
热议问题