例如 有A,B 两个窗体,A上有个textBox 控件 怎么在B窗中访问到 A窗中的textBox.text

解决方案 »

  1.   

    A窗体中:
    B frb=new (this.TextBox.Text);
    frb.ShowDialog();
    B窗体中:
    private string txt;
    public B(string TXT)
    {
    //
    // 
    txt=TXT;
    InitializeComponent(); // Add any initialization after the InitializeComponent() call
    }
    后面就可以对txt(也就是A窗体中的text)进行操作
      

  2.   

    楼上的汗
    其实在A中增加一个Property来访问textbox.text就可以了
    public TextBoxText{
      get{
        return this.textBox.Text;
      }
      set{
        this.textBox.Text = value;
      }
    }
      

  3.   

    public TextBoxText{
      get{
        return this.textBox.Text;
      }
      set{
        this.textBox.Text = value;
      }
    }增加属性的方法是最好的.