We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

textbox

Thread ID:

Created:

Updated:

Platform:

Replies:

38385 Dec 12,2005 12:54 AM Dec 13,2005 07:23 AM Windows Forms 4
loading
Tags: Tools
resmi
Asked On December 12, 2005 12:54 AM

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

Mano J [Syncfusion]
Replied On December 12, 2005 11:08 AM

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

resmi
Replied On December 12, 2005 11:48 PM

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

Mano J [Syncfusion]
Replied On December 13, 2005 05:18 AM

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

resmi
Replied On December 13, 2005 07:23 AM

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 > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;