如何在winforms中将数据从一个选项卡传输到另一个选项卡 [英] How to transfer data from one tab to another tab in winforms
本文介绍了如何在winforms中将数据从一个选项卡传输到另一个选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是winforms的新学习者。我创建了一个带有两个标签的表单,tab1有一个textbox1,一个按钮tab2有一个文本框2。我的要求是,如果我在textbox1中输入任何数据,如果我点击按钮,则输入的文本应该进入选项卡2的文本框2
我是什么尝试过:
i试图在网上搜索但无法找到正确的
解决方案
< blockquote>除非你把每个标签的内容放到一个单独的UserControl中 - 我通常这样做,因为它使管理更容易 - 然后所有标签上的所有控件都是同一表单的一部分,因此是相同的表单类。
这使得它变得微不足道:
private void MyButton_Click( object sender,EventArgs e)
{
textBox2.text = textBox1.Text;
}
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
解决方案
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:
private void MyButton_Click(object sender, EventArgs e) { textBox2.text = textBox1.Text; }
这篇关于如何在winforms中将数据从一个选项卡传输到另一个选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文