private void supprimerLarticleToolStripMenuItem_Click(object sender, EventArgs e) { Articles article = new Articles(); article.RefArticle = listView.Items[listView.SelectedIndices[0]].Text; DialogResult dr = MessageBox.Show("Voulez vous supprimer l'article " + article.RefArticle + " ? ", "Suppression article", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { article.deleteFromDB(); listView.Items.Remove(listView.Items[listView.SelectedIndices[0]]); listView.Refresh(); } }
private void listView_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { modificationArticle(); } else if (e.KeyCode == Keys.Delete) { Articles article = new Articles(); article.RefArticle = listView.Items[listView.SelectedIndices[0]].Text; DialogResult dr = MessageBox.Show("Voulez vous supprimer l'article " + article.RefArticle + " ? ", "Suppression article", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { article.deleteFromDB(); listView.Items.Remove(listView.Items[listView.SelectedIndices[0]]); listView.Refresh(); } } else if (e.KeyCode == Keys.F5) { refreshListView(); } }