如何将数据从子窗体发送到父窗体. [英] how to send data from child form to the parent form.
问题描述
有人可以帮我的代码吗?
我会非常感激:)
记住!没有人会为您编写代码.如果您需要代码方面的帮助,则需要首先下功夫,我们将..随便,
您可以有 [链接与事件之间的表单间通讯 [ http://bytes.com/topic/c-sharp/answers/696941-instance-name-main-form#post2769458 [ ^ ]
i have to forms,the owner and the child. and i want to send data back to the parent form from the child.the data can successfully be sent to the parent form , but the problem is that the parent form opens in the new window.. and i get two windows !! but i really want the updated window not the older window, after the operation.
can some body help me with the code ???
i''ll be very thankful :)
Remember! No one will write code for you. if you need help with code then you need to put your effort first then we will.. whatever,
You can go there[^] to take a look about how to Passing values between Forms.
and this Link-Inter Form Communication with Event[^] might help you
Hi Hanifuk ,
first you must create an overloaded constructor in form2 and a global object of form1 , your already existing default constructor is :
public Form2() { InitializeComponent(); }
The global object and the overloaded constructor code will be :
public static Form1 Frm1 = new Form1(); public Form2(Form1 form) { InitializeComponent(); Frm1 = form; }
Now you can set your control in form1 ''s modifier to public .
Then in the click add button event you will insert this code for opening form2 :
Form2 Frm2 =new Form2(this); Frm2.show();
now in the form2 code you can update your control in form1.
I Hope this help you ,
Good luck
Here is example how you can send data to main form
http://bytes.com/topic/c-sharp/answers/696941-instance-name-main-form#post2769458[^]
这篇关于如何将数据从子窗体发送到父窗体.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!