private void toDoListView_DoubleClick(object sender, EventArgs e) { if (toDoListView.SelectedItems.Count < 1) { return; } ListViewItem selectedItem = toDoListView.SelectedItems[0]; TaskEditorForm taskEditorForm = new TaskEditorForm(); Task task = new Task() { DateTimeByExecute = DateTime.Parse(selectedItem.SubItems[0].Text), Title = selectedItem.SubItems[1].Text }; DialogResult dialogResult = taskEditorForm.ShowDialog(task); if (dialogResult == DialogResult.OK) { selectedItem.SubItems[0].Text = taskEditorForm.ChangedTask.DateTimeByExecute.ToString(); selectedItem.SubItems[1].Text = taskEditorForm.ChangedTask.Title; } }
private void addTaskButton_Click(object sender, EventArgs e) { TaskEditorForm taskEditorForm = new TaskEditorForm(); DialogResult dialogResult = taskEditorForm.ShowDialog(); if (dialogResult == DialogResult.OK) { ListViewItem item = new ListViewItem(); item.SubItems[0].Text = taskEditorForm.ChangedTask.DateTimeByExecute.ToString(); item.SubItems.Add(taskEditorForm.ChangedTask.Title); toDoListView.Items.Add(item); } }