1.父窗体接收子窗体的返回值:
public partial class Form1: Form { private void btnOpen_Click(object sender, EventArgs e) { FrmCorpDTAdd fd = new FrmCorpDTAdd(dsService); if (fd.ShowDialog() == DialogResult.Cancel) //打开子窗体,,并且关闭后 { RetRowGuid = fd._RetRowGuid; //此处接收子窗体的值 } } }
public partial class Form2 : Form { public string _RetRowGuid; //定义共有的全局变量方便其他窗体访问,记录返回到父窗体的值 private void btnSave_Click(object sender, EventArgs e) { _RetRowGuid = dgSG_AptitudeProject.CurrentRow.Cells["RowGuid"].Value.ToString(); //dataGridView选中行的RowGuid值赋给全局变量_RetRowGuid this.DialogResult = DialogResult.Cancel; //取消(关闭) } }
后期会加工修改。。。