简体   繁体   中英

access text of textbox1 in tabPage1 from tabPage2 in C# visual studio

I am writing my code in Visual Studio 2013 , c# . I have a tabControl , it has 2 tabs. there is a textbox in tab 1 ! I want to copy its text to a label in tab2 !

how can I do this?

can it be like :

label1.text = tabPage1.TextBox1.text;

I know it cannot be coz there is no TextBox1 when I write tabPage1 . !

any idea?

I got the answer. All controls of a TabPage are local to a Form and accessible from the Form without adding any additional functionality. so only this line will work:

Label1.text = TextBox1.Text;

thank you all

您正在直接访问标签,为什么不使用文本框也可以这样做?

label1.Text = textBox1.Text;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM