private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; y.setValue(row); this.Close(); }