private void elementsListView_DoubleClick(object sender, EventArgs e) { if (elementsListView.SelectedItems.Count < 1) { return; } ListViewItem selectedItem = elementsListView.SelectedItems[0]; Element editableElement = new Element { Task = selectedItem.SubItems[0].Text, LeadTime = DateTime.Parse(selectedItem.SubItems[1].Text) }; ElementEditorForm elementEditor = new ElementEditorForm(); var res = elementEditor.ShowDialog(editableElement); if (res == DialogResult.OK) { selectedItem.SubItems[0].Text = editableElement.Task; selectedItem.SubItems[1].Text = editableElement.LeadTime.ToString(); DataRefresh(); } }
private void elementEditorButton_Click(object sender, EventArgs e) { ElementEditorForm elementEditor = new ElementEditorForm(); var result = elementEditor.ShowDialog(); Element newElement = elementEditor.EditableElement; if (result == DialogResult.OK) { ListViewItem newItem = new ListViewItem(); newItem.SubItems[0].Text = newElement.Task; newItem.SubItems.Add(newElement.LeadTime.ToString()); elementsListView.Items.Add(newItem); DataRefresh(); } }