private void mnuEditItem_Click(object sender, EventArgs e) { if (lvMain.SelectedItems.Count <= 0) return; var editform = new frmEdit(settings); editform.ActionContainer.action = settings.Payload.Actions[ lvMain.SelectedIndices[0]]; if (editform.ShowDialog() == DialogResult.OK) { settings.Payload.Actions[int.Parse(lvMain.SelectedItems[0].Text) - 1] = editform.ActionContainer.action; SetDirty(); lvMain.SelectedItems[0].SubItems[1].Text = editform.ActionContainer.action.GetTypeName(); lvMain.SelectedItems[0].SubItems[2].Text = editform.ActionContainer.action.GetDetails(); } }
private void mnuAddNew_Click(object sender, EventArgs e) { var addnew = new frmEdit(settings); addnew.ActionContainer.action = null; if (addnew.ShowDialog() == DialogResult.OK) { // update the database settings.Payload.Actions.Add(addnew.ActionContainer.action); // update the listview lvMain.Items.Add(new ListViewItem(new string[]{ settings.Payload.Actions.Count.ToString(), addnew.ActionContainer.action.GetTypeName(), addnew.ActionContainer.action.GetDetails(), "" })); lvMain.FocusedItem = lvMain.Items[lvMain.Items.Count - 1]; // set the dirty flag SetDirty(); } }