private void taskDeleteButton_Click(object sender, EventArgs e) { int selectedrowindex = taskDataGridView.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = taskDataGridView.Rows[selectedrowindex]; string taskNameFromGrid = Convert.ToString(selectedRow.Cells["tasknameDataGridViewTextBoxColumn"].Value); if (taskNameText.Text == "") { MessageBox.Show("Please select a record to delete.", "Delete Status", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (taskDescText.Text == "") { MessageBox.Show("Please re-select the correct record to delete. " + Environment.NewLine + Environment.NewLine + "Selected record and displayed informations are diefferent" + Environment.NewLine + Environment.NewLine + "(HINT: Try clicking different column or try double click different column)", "Delete Status", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //else if (taskNameText.Text != taskNameFromGrid) //{ // MessageBox.Show("Please re-select the correct record to delete. " + Environment.NewLine + Environment.NewLine + "Selected record and displayed informations are diefferent" + Environment.NewLine + Environment.NewLine + "(HINT: Try clicking different column or try double click different column)", "Delete Status", MessageBoxButtons.OK, MessageBoxIcon.Warning); //} //else if (!(taskoneoffrbutton.checked) && !(taskmonthlyrbutton.checked) && // !(taskweeklyrbutton.checked) && !(taskyearlyrbutton.checked) == true) //{ // messagebox.show("please re-select the correct record to delete. " + environment.newline + environment.newline + "selected record and displayed informations are diefferent" + environment.newline + environment.newline + "(hint: try clicking different column or try double click different column)", "delete status", messageboxbuttons.ok, messageboxicon.warning); //} else { cc.TaskName = taskNameText; cc.TaskDueDate = taskDueDateBox; cc.TaskTimeFrom = taskTimeFromTBox; cc.TaskTimeTo = taskTimeToTBox; cc.TaskLocation = taskLocationText; cc.TaskDescription = taskDescText; cc.TaskAdditionalNote = taskAdditionalText; cc.TaskPriorityLevel = taskPriorityDropDown; cc.TaskContact = taskContactsListDropDown; cc.TaskCategory = taskCategoryRButton; cc.TaskDataGridView = taskDataGridView; cc.deleteTask(); taskNameText.Enabled = true; taskNameText.Text = ""; taskDueDateBox.Text = ""; taskTimeFromTBox.Text = ""; taskTimeToTBox.Text = ""; taskContactsListDropDown.Text = ""; taskLocationText.Text = ""; taskDescText.Text = ""; taskCategoryRButton = ""; taskAdditionalText.Text = ""; taskPriorityDropDown.Text = ""; } }