void ButtonEditClick(ListView list_view_ctrl) { if (0 == list_view_ctrl.SelectedItems.Count) { return; } ListViewItem selectedItem = list_view_ctrl.SelectedItems[0]; List <string> pList = new List <string>(); foreach (ListViewItem.ListViewSubItem item in selectedItem.SubItems) { pList.Add(item.Text); } DeviceEditForm editForm = new DeviceEditForm(list_view_ctrl.Columns.Count, pList); if (DialogResult.OK == editForm.ShowDialog()) { if (0 == editForm.ParaList.Count) { return; } selectedItem.SubItems.Clear(); selectedItem.Text = editForm.ParaList[0]; for (int i = 1; i < editForm.ParaList.Count; i++) { selectedItem.SubItems.Add(editForm.ParaList[i]); } SaveListViewContents(); } }
void ButtonAddClick(ListView list_view_ctrl) { DeviceEditForm editForm = new DeviceEditForm(list_view_ctrl.Columns.Count); if (DialogResult.OK == editForm.ShowDialog()) { ListViewItem item = new ListViewItem(editForm.ParaList[0]); for (int i = 1; i < editForm.ParaList.Count; i++) { item.SubItems.Add(editForm.ParaList[i]); } list_view_ctrl.Items.Add(item); SaveListViewContents(); } }
void ButtonEditClick(ListView list_view_ctrl) { if (0 == list_view_ctrl.SelectedItems.Count) { return; } ListViewItem selectedItem = list_view_ctrl.SelectedItems[0]; List<string> pList = new List<string>(); foreach (ListViewItem.ListViewSubItem item in selectedItem.SubItems) { pList.Add(item.Text); } DeviceEditForm editForm = new DeviceEditForm(list_view_ctrl.Columns.Count, pList); if (DialogResult.OK == editForm.ShowDialog()) { if (0 == editForm.ParaList.Count) { return; } selectedItem.SubItems.Clear(); selectedItem.Text = editForm.ParaList[0]; for (int i = 1; i < editForm.ParaList.Count; i++) { selectedItem.SubItems.Add(editForm.ParaList[i]); } SaveListViewContents(); } }