有窗体form1和窗体form2,现在如何form2中的值传给form1的变量。求高手!!急!!
有窗体form1和窗体form2,现在如何将form1的datatable做为数据源绑定到form2中的DataGridView中。并且当双击form2中的DataGridView中的某一行时将DataGridView中这一行中的第一列的值付给form1中的strNewcode变量,同时form1关闭。这个怎么实现?求详解!!这是我自己写的代码,但不能实现,求大虾们指点下。form1中的部分代码form2selectbill = new form2();
selectbill.dgvBillInfor.DataSource = dtNew;
selectbill.Visible = false;
string strNewcode = "";
selectbill.Returnvalue = new SelectBill.retunvalue(Showvalue);
selectbill.ShowDialog();form2中的部分代码 public delegate void retunvalue(string strBillcode);
public retunvalue Returnvalue;
private void dgvBillInfor_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0 || e.RowIndex < 0) return;
DataGridViewRow dgvrBill = dgvBillInfor.CurrentRow;
if (dgvrBill != null)
{
string strBillCode = dgvrBill.Cells["Cwcwewbcode"].Value.ToString();
if (string.IsNullOrEmpty(strBillCode)) return;
Returnvalue(strBillCode);
}
}