简体   繁体   中英

Passing Value from One form to another on click of datagrid View Row

I got 2 forms:

Ist form contain(Main form) : Datagridview, Save button and 'Search Employee' button. 2nd form contain : Datagridview and select button .

When i click button search employee button from main form. It open 2nd form and show details of all employees such as first_name, id, salary in dataGridView. When i select any row from that dataGridView and click the button 'Select' it pass the detail of that employee to main form datagridview.

If i repeat this process then it will opnen new main fram with that particular recod nd do not add selected record to previous datagridview. so how i can implement this.

frmMain frmMain = new frmMain();
frmMain.Close();
frmMain frmmain = new frmMain(
dataGridView1.SelectedRows[0].Cells[0].Value.ToString(), 
dataGridView1.SelectedRows[0].Cells[1].Value.ToString(), 
dataGridView1.SelectedRows[0].Cells[2].Value.ToString(), 
dataGridView1.SelectedRows[0].Cells[3].Value.ToString(),
dataGridView1.SelectedRows[0].Cells[4].Value.ToString());

this.Hide();
rmmain.Show();

您可以在一个页面上声明公共形式,当您导航到另一页面时,将此变量传递给this.page这样的整个表单,然后访问该变量和所有函数

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM