private void addButton_Click(object sender, EventArgs e) { var dialog = new InputExtensionDialog(); if (dialog.ShowDialog(this) == DialogResult.OK) { ListViewItem item = new ListViewItem(new[] { String.Empty, dialog.Filter.ExtensionsString, dialog.Filter.Description }); extensionsView.Items.Add(item); } }
private void editButton_Click(object sender, EventArgs e) { var item = extensionsView.SelectedItems.Cast<ListViewItem>().DefaultIfEmpty(null).First(); if (item == null) { MessageBox.Show(this, "項目が選択されていません。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var filter = new ExtensionFilter(false, item.SubItems[1].Text, item.SubItems[2].Text); var dialog = new InputExtensionDialog(filter); if (dialog.ShowDialog(this) == DialogResult.OK) { item.SubItems[1].Text = dialog.Filter.ExtensionsString; item.SubItems[2].Text = dialog.Filter.Description; } }