private void buttonEditSelected_Click(object sender, EventArgs e) { int index = listBox1.SelectedIndex; if (index < 0 || index >= articles.Count) { MessageBox.Show("Choose 1 article!"); return; } ArticleEditForm articleForm = new ArticleEditForm(articles[index], authors); var res = articleForm.ShowDialog(); if (res == DialogResult.OK) { Article article = new Article(articles[index]); //hack to make articles notify listBox about state change articles.Add(article); articles.RemoveAt(index); } else if (res != DialogResult.Abort) { MessageBox.Show("Nothing changed"); } }
private void addArticle_Click(object sender, EventArgs e) { Article article = new Article(); ArticleEditForm articleForm = new ArticleEditForm(article, authors); var res = articleForm.ShowDialog(); if (res == DialogResult.OK) { articles.Add(article); } else if (res != DialogResult.Abort) { MessageBox.Show("Nothing changed"); } }