void addItem(object sender, EventArgs e) { using (BackupEventTaskInfoEditingForm form = new BackupEventTaskInfoEditingForm(_isBeforeBackupEvent)) { if (form.ShowDialog() == DialogResult.OK) { addTaskInfoToList(form.EventTask); } } tasksListViewSelectedIndexChanged(sender, e); }
void editSelectedItem(object sender, EventArgs e) { if (tasksListView.SelectedItems.Count != 1) { return; } int indexOfItem = tasksListView.SelectedItems[0].Index; using (BackupEventTaskInfoEditingForm form = new BackupEventTaskInfoEditingForm(_isBeforeBackupEvent, (BackupEventTaskInfo)tasksListView.SelectedItems[0].Tag)) { if (form.ShowDialog() == DialogResult.OK) { BackupEventTaskInfo task = form.EventTask; tasksListView.SelectedItems[0].SubItems[0].Text = task.Program; tasksListView.SelectedItems[0].SubItems[1].Text = task.Arguments; tasksListView.SelectedItems[0].Tag = task; } } }