我有两种形式(frmMain和frmchild_list)。当我点击frmMain中的按钮时,frmchild_list将弹出,数据现在填充到datagridview中。如果单击frmchild_list中的数据行,我想将选定的datagridview的值传递给parent中的textbox。子datagridview父级文本框winform
这里我的代码在父
private void button2_Click(object sender, EventArgs e)
{
if(radioButton1.Checked)
{
f1.frmchild_list f = new f1.frmchild_list(this, "Y");
f.MdiParent = this;
f.Show();
}
else
{
f1.frmchild_listf = new f1.frmchild_list(this, "N");
f.MdiParent = this;
f.Show();
}
}
public static string itemx
{
set
{
txtItem.Text = value;
}
}
我的代码中的孩子:
Form m_parent;
public frmIdH(Form f, string loc)
{
InitializeComponent();
loaddata(loc);
m_parent = f;
}
public void loaddata(string location)
{...}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
m_parent.itemx = "sss";
}