using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace ToDoListWM5 { public partial class Form1 : Form { private Model toDoListModel;
public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { toDoListModel = new Model(); this.deleteToDoItemsView1.ViewData = toDoListModel.ToDoListViewData; this.deleteToDoItemsView1.Visible = true; this.addToDoItemView1.Visible = false; } private void menuItem2_Click(object sender, EventArgs e) { switch (((MenuItem)sender).Text) { case "Delete": { toDoListModel.DeleteToDoListItems(this.deleteToDoItemsView1.ViewItemsToDelete); this.deleteToDoItemsView1.ViewData = toDoListModel.ToDoListViewData; this.menuItem1.Text = "Add"; this.menuItem2.Text = "Delete"; this.deleteToDoItemsView1.Visible = true; this.addToDoItemView1.Visible = false; break; } case "OK": { toDoListModel.AddToDoListItem(this.addToDoItemView1.ViewItemToAdd); this.deleteToDoItemsView1.ViewData = toDoListModel.ToDoListViewData; this.menuItem1.Text = "Add"; this.menuItem2.Text = "Delete"; this.deleteToDoItemsView1.Visible = true; this.addToDoItemView1.Visible = false; break; } } } private void menuItem1_Click(object sender, EventArgs e) { switch (((MenuItem)sender).Text) { case "Add": { this.addToDoItemView1.ViewData = toDoListModel.ToDoListViewData; this.menuItem1.Text = "BACK"; this.menuItem2.Text = "OK"; this.deleteToDoItemsView1.Visible = false; this.addToDoItemView1.Visible = true; break; } case "BACK": { this.deleteToDoItemsView1.ViewData = toDoListModel.ToDoListViewData; this.menuItem1.Text = "Add"; this.menuItem2.Text = "Delete"; this.deleteToDoItemsView1.Visible = true; this.addToDoItemView1.Visible = false; break; } } } //add code here to make sure that one checkbox thingy is check only private void deleteToDoItemsView1_Click(object sender, EventArgs e) { if (CheckState = checked){ this.deleteToDoItemsView1.ViewItemsToDelete.RemoveToDoListRow();
}
} } }
|