void btnEdit_Click(object sender, EventArgs e) { try { int index = lvData.SelectedIndices[0]; double[] arrData = new double[lvData.Columns.Count]; for (int i = 0; i < arrData.Length; i++) { arrData[i] = arrSmp[i][index]; } EditDataForm edForm = new EditDataForm(arrColName, arrData); if (edForm.ShowDialog() != DialogResult.OK) { return; } string[] arrStr = new string[lvData.Columns.Count]; double[] arrValue = edForm.GetData(); for (int i = 0; i < lvData.Columns.Count; i++) { arrSmp[i][index] = arrValue[i]; arrStr[i] = arrValue[i].ToString(); } lvData.Items.RemoveAt(index); lvData.Items.Insert(index, new ListViewItem(arrStr)); } catch { } }
void btnAdd_Click(object sender, EventArgs e) { double[] arrData = new double[lvData.Columns.Count]; EditDataForm edForm = new EditDataForm(arrColName, arrData); if (edForm.ShowDialog() != DialogResult.OK) { return; } string[] arrStr = new string[lvData.Columns.Count]; double[] arrValue = edForm.GetData(); for (int i = 0; i < lvData.Columns.Count; i++) { arrSmp[i].AddValue(arrValue[i]); arrStr[i] = arrValue[i].ToString(); } lvData.Items.Add(new ListViewItem(arrStr)); }