你的位置:首页 > ASP.net教程

[ASP.net教程]Windowsform datagridview选中向父窗口传值


Datagridview mouseclick事件

private void dataGridView1_MouseClick(object sender, MouseEventArgs e)

{

int a = dataGridView1.CurrentRow.Index;

string str = dataGridView1.Rows[a].Cells["department"].Value.ToString();

textBox1.Text = str;

}

 

Button事件向父窗口传值

private void button1_Click(object sender, EventArgs e)

{

assetinsert fm = (assetinsert)this.Owner;

//注意 如果textBox1是放在panel1中的 则先找panel1 再找textBox1

((TextBox)fm.Controls["textBox1"]).Text = this.textBox1.Text;

this.Close();

}