两种方法:
一:在From2的 public Form2()中问号里添加 string strTxt
既 public Form1(string strTxt)
{
InitializeComponent();
this.textBox1.Text=strTxt;
}
在Form1的Button click 事件里
{
From2 f=new Form2(this.textBox1.Text.toString())
f.show();
}
二:
在Form2中申明一个属性
string strTxt=“”:
public string StrTxt
{
get{ return strTxt: }
set{ strTxt=value: }
}
然后在窗体加载里写入 this.textBox1.Text=this.StrTxt;
在Form1的Button click 事件里
{
Form2 f=new Form2();
f.StrTxt=this.textBox.Text.toString();
f.show();
}
第一种方法方便,第二种推荐使用,安全性高
追问![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/a5c27d1ed21b0ef461c3f556dfc451da81cb3e8a?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
这个是用vb.net写的,画波浪线提示出错了
前面还有默认参数,这个应该怎么传递呢
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/64380cd7912397ddae3bf70c5b82b2b7d0a28773?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/b21c8701a18b87d69c67c617050828381f30fd95?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)