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.

Recommended Answers

All 3 Replies

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.

you haven't show any proof of effort.

Which apparently includes searching other posts in this forum.

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;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.