private void addServiceBtn_Click(object sender, EventArgs e) { using (var f = new AddEditServiceForm()) { var result = f.ShowDialog(); if (f.DialogResult != DialogResult.OK || f.Service == null) { return; } this.servicesListBox.Items.Add(f.Service); SaveConfiguration(); } }
void EditServiceByListIndex(int index) { var service = (Service)this.servicesListBox.Items[index]; using (var f = new AddEditServiceForm(service)) { var result = f.ShowDialog(); if (f.DialogResult != DialogResult.OK) { return; } this.servicesListBox.Items[index] = f.Service; SaveConfiguration(); } }