private void frmMain_Load(object sender, EventArgs e) { TaskListUtil.TaskList = TaskTextfileUtil.Read(); lstTasks.Items.Add("Task Description \t" + "Task Date \t\t" + "Task Priority"); for (int i = 0; i < TaskListUtil.TaskList.Count; i++) { lstTasks.Items.Add(taskDescription + "\t" + taskDateAndTime.Date + "\t\t" + cmbTaskPriority.SelectedItem); } }
private void btnAddTask_Click(object sender, EventArgs e) { taskDescription = txtTaskDescription.Text; taskDateAndTime = dtpDateTimePicker.Value; taskPriority = cmbTaskPriority.SelectedIndex; Task task = new Task(taskDescription, taskDateAndTime, taskPriority); lstTasks.Items.Add(taskDescription + "\t" + taskDateAndTime.Date + "\t" + cmbTaskPriority.SelectedItem); TaskListUtil.TaskList.Add(task); try { TaskTextfileUtil.Write(task); } catch { MessageBox.Show("Something went wrong"); } }