我在第一个页面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显示是空的
请教

解决方案 »

  1.   

    在 InformationWrite.cs 中这样打开 TechnologyInformation 窗口:private void b_xyb_Click(object sender, System.EventArgs e)
    {
         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;
    }
      

  2.   

    你可以把t_name.Text付给一个静态的字符串,然后在TechnologyInformation.cs里调用这个静态字符串
      

  3.   

    注意你原来的程序中:
    InformationWrite iw=new InformationWrite();这样是实例化了InformationWrite类,亦即 InformationWrite 类的 t_name 会被重置为初始值。iw 将会一个新对象,已经不是打开 TechnologyInformation 窗口的那个对象了。
      

  4.   

    to:xrascal
    出现这样的问题, 重载“Show”方法未获取“1”参数
      

  5.   

    哦,手误手误。
    hoho TechnologyInformation ti=new TechnologyInformation(this.t_name);
    ti.Show();
      

  6.   

    其实你为何不在 TechnologyInformation窗体上加一个属性呢?
    如下
    privaite string txtname;
    publick string iname
    {
      set{txtname=value;}
    }好象是这样写.然后在new TechnologyInformation之后设置iname的值
      

  7.   

    还有一个get{return value}呵呵