一:
父类窗体添加一个public公用方法,开放给子窗体使用
父:public void SetHellow(string txt)
{
textBox1.Text = txt;
}
子:private void button1_Click(object sender, EventArgs e)
{
FromFather from = new FromFather();
from.SetHellow(textBox1.Text);
}
二:
子窗体有父窗体对象
父: new FormSon(textBox1.Text).Show();
子:定义一个静态属性
public string Msg { get; set; }
添加一个构造方法
public Form1(string txt)
{
InitializeComponent();
Msg = txt;
textBox1.Text = Msg;
}
winfrom窗体之间传值
最新推荐文章于 2024-07-23 17:34:53 发布