private void buttonAdd_Click(object sender, EventArgs e) { FormAdd formadd = new FormAdd(); formadd.ShowDialog(); labelNotice.Text = "添加成功"; }
private void buttonAdd_Click(object sender, EventArgs e) { FormAdd addForm = new FormAdd(); if (addForm.ShowDialog() == DialogResult.OK) { TaskEntry task = new TaskEntry(); task.Name = addForm.Name; task.TaskDate = (DateTime?)addForm.TaskDate; task.IsDone = addForm.IsDone; AddTask(task); } }
public Form1ViewModel() { OnAdd = new MVVMRelayCommand(value => { FormAdd formAdd = new FormAdd(); MVVMControlBase control = formAdd.Build(); if (formAdd.ShowDialog() == DialogResult.OK) { Items.Add(control.DataContext.GetTargetValue <FormAddViewModel> ().Item); } }); OnEdit = new MVVMRelayCommand <Item> (value => { FormAdd formAdd = new FormAdd(value.DeepClone()); MVVMControlBase control = formAdd.Build(); if (formAdd.ShowDialog() == DialogResult.OK) { Items[Items.IndexOf(value)] = control.DataContext.GetTargetValue <FormAddViewModel> ().Item; } }); OnDelete = new MVVMRelayCommand <Item> (value => { Items.Remove(value); }); }