我在第一个页面InformationWrite.cs 将里面的控件
设置为公共的public System.Windows.Forms.TextBox t_name;
在 private void b_xyb_Click(object sender, System.EventArgs e)
{
TechnologyInformation ti=new TechnologyInformation();
ti.Show();
}
打开第二页页面TechnologyInformation.cs
在第二个页面中 public void NameData()
{
InformationWrite iw=new InformationWrite();
t_ygmc.Text=iw.t_name.Text;
}
这个t_ygmc是第二个页面中的控件,可是问题在于没有取到传递的过来的值,怎么回事呢
这个t_ygmc显示是空的
请教
设置为公共的public System.Windows.Forms.TextBox t_name;
在 private void b_xyb_Click(object sender, System.EventArgs e)
{
TechnologyInformation ti=new TechnologyInformation();
ti.Show();
}
打开第二页页面TechnologyInformation.cs
在第二个页面中 public void NameData()
{
InformationWrite iw=new InformationWrite();
t_ygmc.Text=iw.t_name.Text;
}
这个t_ygmc是第二个页面中的控件,可是问题在于没有取到传递的过来的值,怎么回事呢
这个t_ygmc显示是空的
请教
{
TechnologyInformation ti=new TechnologyInformation();
ti.Show(this.t_name);
}
在 TechnologyInformation.cs
添加构造函数:public TechnologyInformation(System.Windows.Forms.TextBox t_name)
{
t_ygmc.Text=t_name.Text;
}
InformationWrite iw=new InformationWrite();这样是实例化了InformationWrite类,亦即 InformationWrite 类的 t_name 会被重置为初始值。iw 将会一个新对象,已经不是打开 TechnologyInformation 窗口的那个对象了。
出现这样的问题, 重载“Show”方法未获取“1”参数
hoho TechnologyInformation ti=new TechnologyInformation(this.t_name);
ti.Show();
如下
privaite string txtname;
publick string iname
{
set{txtname=value;}
}好象是这样写.然后在new TechnologyInformation之后设置iname的值