private void FindListBox_MouseDoubleClick(object sender, MouseEventArgs e) { int n = FindListBox.IndexFromPoint(e.Location); if (n != ListBox.NoMatches) { FindListBox.SelectedIndex = n; var addTaskForm = new AddTaskForm(_diaryPreferences); addTaskForm.DiaryTask = _displayedFindDiaryTaskList.TaskList[n]; var changedTask = _displayedFindDiaryTaskList.TaskList[n]; if (addTaskForm.ShowDialog() == DialogResult.OK) { var index = _diaryTaskList.TaskList.FindIndex(x => CompareDate(x.TaskDate, changedTask.TaskDate, true) && x.Name == changedTask.Name); RemoveDiaryTask(index); //_diaryTaskList.TaskList.RemoveAt(index); _diaryTaskList.TaskList.Add(addTaskForm.DiaryTask); _displayedFindDiaryTaskList.TaskList.RemoveAt(n); _displayedFindDiaryTaskList.TaskList.Add(addTaskForm.DiaryTask); Find_Click(sender, e); UpdateFindList(); _displayedDiaryTaskList = _diaryTaskList; UpdateMainList(); } } }
private void Add_Click(object sender, EventArgs e) { var addTaskForm = new AddTaskForm(_diaryPreferences); if (addTaskForm.ShowDialog() == DialogResult.OK) { _diaryTaskList.TaskList.Add(addTaskForm.DiaryTask); _displayedDiaryTaskList = _diaryTaskList; UpdateMainList(); } }