// BUTTONS EVENT private void button_add_Click(object sender, EventArgs e) { // creating an array for receive the settings from the new form string[] allParams = null; // build listview group for sending it to the new form List <string> allGroup = new List <string>(); foreach (ListViewGroup group in listView_filament.Groups) { allGroup.Add(group.Header); } // Open the new form using (addEdit_form OpenForm = new addEdit_form(host, allGroup)) { OpenForm.ShowDialog(); allParams = OpenForm.allParams; } if (allParams == null) { return; } // Creating the item and add into the listview createAddNewItem(allParams); // Save data in the registry saveRegistry(); }
private void button_edit_Click(object sender, EventArgs e) { // if no item selected in the listview return if (listView_filament.SelectedItems.Count == 0) { return; } // build listview group for sending it to the new form List <string> allGroup = new List <string>(); foreach (ListViewGroup group in listView_filament.Groups) { allGroup.Add(group.Header); } // build an array with all settings, for sending it to the new form // 0: Name; 1:diameter; 2:ExMulti; 3:temp; 4:coust; 5:density; 6:note; 7:group string[] allParams = new string[8]; allParams[0] = listView_filament.SelectedItems[0].SubItems[0].Text; allParams[1] = listView_filament.SelectedItems[0].SubItems[1].Text; allParams[2] = listView_filament.SelectedItems[0].SubItems[2].Text; allParams[3] = listView_filament.SelectedItems[0].SubItems[3].Text; allParams[4] = listView_filament.SelectedItems[0].SubItems[4].Text; allParams[5] = listView_filament.SelectedItems[0].SubItems[5].Text; allParams[6] = listView_filament.SelectedItems[0].SubItems[6].Text; allParams[7] = listView_filament.SelectedItems[0].Group.Header; // Open the new form with the item editor using (addEdit_form OpenForm = new addEdit_form(host, allGroup, allParams)) { OpenForm.ShowDialog(); //copy the new settings in the array allParams = OpenForm.allParams; } if (allParams == null) { return; } // remove the old item from listview and add a new item with new params listView_filament.BeginUpdate(); listView_filament.Items.Remove(listView_filament.SelectedItems[0]); createAddNewItem(allParams); listView_filament.EndUpdate(); // Save data in the registry saveRegistry(); }