private void buttonDeleteCompany_Click(object sender, EventArgs e) { try { var result = MessageBox.Show("Are you sure ?", "Confirmation", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { connectionDB.deleteCompanyFromList(comboBoxCompany.Text, comboBoxEmail.Text, comboBoxList.Text); // Use method to delete a company in the list comboBox1_SelectedIndexChanged(null, null); } } catch { MessageBox.Show("Error, the list is not updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }