private void butOK_Click(object sender, EventArgs e) { if (listBoxPick.SelectedItems.Count == 0) { MsgBox.Show(this, "Please select an item in the list first."); return; } Field.FieldValue = listBoxPick.SelectedItem.ToString(); if (Field.FieldValue == "") //If blank, then delete { if (IsNew) { DialogResult = DialogResult.Cancel; return; } ApptFields.Delete(Field.ApptFieldNum); DialogResult = DialogResult.OK; return; } if (IsNew) { ApptFields.Insert(Field); } else { ApptFields.Update(Field); } DialogResult = DialogResult.OK; }
/*private void buttonDelete_Click(object sender,EventArgs e) { * * }*/ private void butOK_Click(object sender, System.EventArgs e) { Field.FieldValue = textValue.Text; if (Field.FieldValue == "") //if blank, then delete { if (IsNew) { DialogResult = DialogResult.Cancel; return; } ApptFields.Delete(Field.ApptFieldNum); DialogResult = DialogResult.OK; return; } if (IsNew) { ApptFields.Insert(Field); } else { ApptFields.Update(Field); } DialogResult = DialogResult.OK; }