Click here to Skip to main content
15,905,419 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am a new learner of winforms. i have created a form with two tabs, tab1 has a textbox1 and a button tab2 has a text box2. My requirement is that if i enter any data in textbox1 and if i click on button,that entered text should get in the textbox2 of tab 2

What I have tried:

i have tried searching for this online but couldnt get the right one
Posted
Comments
CHill60 1-Feb-18 8:08am    
Share the code you have tried. Why can't you just assign the value to the second textbox when you leave the first one?
Sinisa Hajnal 1-Feb-18 8:49am    
All controls are on the same form. Just put text2.Text = text1.Text on button click. If you want to avoid button click you can use Leave event of the text1.

1 solution

Unless you put the contents of each tab into a separate UserControl - and I generally do as it makes it easier to manage - then all the controls on all the tabs are parts of the same form, and so the same form class.
Which makes it trivial:
C#
private void MyButton_Click(object sender, EventArgs e)
    {
    textBox2.text = textBox1.Text;
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900