winform窗体之间的传值

资料整理结果如下

1.

子窗体做一个属性    
  子窗体的确定按钮里面给这个属性赋值   
  父窗体直接访问这个属性就好了

  FrmChoiceProduct FormChild = new FrmChoiceProduct();
            FormChild.Owner = this;
            FormChild.ShowDialog();
            txtWeight.Text = FormChild.strWeight;

private   string   inputValue   =   "";  
  public   string   InputValue  
  {  
        get{return   inputValue;}  
  }  
   
   
  confirm_buttonClick.....  
  {  
        inputValue=   TextBox1.Text.Trim();  
        this.DialogResult   =   DialogResult.OK;  
  }  
   
   
  父窗体  
   
  childForm   cf   =   new   childForm();  
  string   varReturnValue   =   "";  
  if(cf.ShowDialog()   ==   DialogResult.OK)  
  {  
        varReturnValue     =   cf.InputValue    
  }

原文地址:https://www.cnblogs.com/meetweb/p/1289731.html