textbox

Hi I want to know how to pass datas Between forms.ie,I''ve one form with 1 textbox and 1 button.When i click on this button another form with 1 textbox & a button will come.What I want is when I click on the button in the second form ,the value inthe textbox of the second form should come inthe first form''s textbox also. Now I''ve written code in the paint event.But this will not work inthe button click.So give me a solution Thanks resmi

4 Replies

MJ Mano J Syncfusion Team December 12, 2005 04:08 PM UTC

Hi Resmi, You could call the MainForm from the childForm by creating a method as shown below in the child form. private MainForm mainForm; public void StoreSender(MainForm form) { this.mainForm = form; } private void button1_Click(object sender, System.EventArgs e) { Form2 f = new Form2(); f.StoreSender((MainForm)this); f.Show(); } Now you could access the controls on the mainForm in the button_click event as follows: private void button2_Click(object sender, System.EventArgs e) { this.mainForm.textBox1.Text=this.textBox2.Text; } I have attached a sample which illustrates this completely. Please let me know if this meets your requirements. Regards, Mano Test_1.zip


RE resmi December 13, 2005 04:48 AM UTC

Thanks Mano.It works fine.One more thing I want to know.If Iam opening these 2 forms from a third form which is having a menu,how can I solve the same problem >Hi Resmi, > >You could call the MainForm from the childForm by creating a method as shown below in the child form. > >private MainForm mainForm; >public void StoreSender(MainForm form) >{ > this.mainForm = form; >} > >private void button1_Click(object sender, System.EventArgs e) >{ > Form2 f = new Form2(); > f.StoreSender((MainForm)this); > f.Show(); >} > >Now you could access the controls on the mainForm in the button_click event as follows: > >private void button2_Click(object sender, System.EventArgs e) >{ > this.mainForm.textBox1.Text=this.textBox2.Text; >} > > >I have attached a sample which illustrates this completely. Please let me know if this meets your requirements. > >Regards, >Mano > >Test_1.zip >

Text_passing.zip


MJ Mano J Syncfusion Team December 13, 2005 10:18 AM UTC

Hi Resmi, Thanks for the update. I have modified your sample as per your requirements. Please refer to it and let me know if this helps you. Regards, Mano Text_passing.zip


RE resmi December 13, 2005 12:23 PM UTC

Thanks Mano It''s working . Resmi >Hi Resmi, > >Thanks for the update. I have modified your sample as per your requirements. Please refer to it and let me know if this helps you. > >Regards, >Mano > >Text_passing.zip > >

Loader.
Up arrow icon