private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { try { string id = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); if (e.ColumnIndex == 8) { DialogResult dr = MessageBox.Show("คุณต้องการลบข้อมูลนี้หรือไม่ ?", "ลบข้อมุล", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { this.deleteData(id); } } if (e.ColumnIndex == 7) { SparesAdd da = new SparesAdd(this); da.ID = id; da.Show(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void button2_Click(object sender, EventArgs e) { SparesAdd acf = new SparesAdd(this); acf.Show(); }