private void OnEdit(object sender, EventArgs e) { var item = GetSelectedContact(); if (item == null) { return; } var form = new ContactForm { Text = "Edit Contact", Contact = item }; if (form.ShowDialog(this) == DialogResult.Cancel) { return; } _contactDatabase.Edit(item.Name, form.Contact); RefreshContacts(); }