private void btnDeleteAppointment_Click(object sender, System.EventArgs e) { DataGridViewRow r = dgvData.SelectedRows[0]; if (r != null) { if (MetroFramework.MetroMessageBox.Show(this, "Are you sure?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { q.DeleteAppointment(r.Cells[0].Value.ToString()); try { dgvData.Rows.Remove(r); } catch (Exception exception) { } } } }