private void addToolStripMenuItem_Click(object sender, EventArgs e) { // Add new item to list. ListViewItem item = listView1.Items.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); // Open edit dialog. Edit form = new Edit(item); // If user pressed OK, save changes. // Otherwise, remove item from list. if (form.ShowDialog(this) == DialogResult.Cancel) { listView1.Items.Remove(item); } refreshMenu(); }
protected void showEditDialog() { if (listView1.SelectedItems.Count > 0) { Edit form = new Edit(listView1.SelectedItems[0]); if (form.ShowDialog(this) == DialogResult.OK) { refreshMenu(); } } }