I need a example code to display one form input textbox value in another form textbox when button click event on form one.

In simply form one contain textbox and a button,
form two contain only one textbox.

My requirement is when some one put text into form one textbox and press the form one button, the input data should be disply in the form two textbox.

If any one try this kind of code, kindly request to share with me.

5 Years
Discussion Span
Last Post by ChrisHunter

Just provide a public property in form two that the button click event sets in form one. The setter for the property would invalidate the textbox in form two and cause it to redraw. Easy peasy. And no, I won't give you the code for it because this is clearly homework and you haven't show any proof of effort.

Edited by deceptikon


You have to show that have at least attempted to solve the problem yourself and we're not supposed to give you the code as you might just copy it without understanding it and learning anything from it but the follow the instruction below (the line of code which is also below will put the input from form1 into form2, the rest is up to you).

At the top of Form1 declair an instance of form 2, make sure the textBox in form2 is set to public and do the following:

form2.textBox1.Text = this.textBox1.Text;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.