求个简单的Form1向Form2传值的代码
private void button1_Click_2(object sender, EventArgs e)
{
string str = "你好";
string str1 = "大家好";
Form2 f2 = new Form2();
f2.ShowDialog();
}
在Form2窗体吧 str,str1显示出来
------解决方案--------------------在form2里定义两个属性
public string str
{get;set;}
public string str1
{get;set;}
然后把form1里的str和str1传过去
private void button1_Click_2(object sender, EventArgs e)
{
string str = "你好";
string str1 = "大家好";
Form2 f2 = new Form2();
f2.str=str;
f2.str1=str;
f2.ShowDialog();
}