private void dgvListWorker_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 8) { if (dgvListWorker.CurrentRow != null) { var id = dgvListWorker.CurrentRow.Cells[0].Value; var worker = Worker.SelectedWorker(Convert.ToInt32(id)); var form = new WorkerForm { Worker = worker, WorkerListForm = this, TopLevel = false, Dock = DockStyle.Fill }; CatelogForm.pnlFill.Controls.Clear(); CatelogForm.pnlFill.Controls.Add(form); form.Show(); } } if (e.ColumnIndex == 9) { if (dgvListWorker.CurrentRow != null) { var id = dgvListWorker.CurrentRow.Cells[0].Value; var showDeleteMsg = MessageBox.Show(@"Are you sure want to delete this?", @"Delete", MessageBoxButtons.YesNo); if (showDeleteMsg == DialogResult.Yes) { Worker.Delete(Convert.ToInt32(id)); dgvListWorker.Columns.Clear(); WorkerListForm_Shown(this, new EventArgs()); } if (showDeleteMsg == DialogResult.No) { dgvListWorker.Columns.Clear(); WorkerListForm_Shown(this, new EventArgs()); } } } }