void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbName.Text)) { MessageBox.Show("You must enter a name for the item."); return; } key = new KeyData(); key.Name = tbName.Text; key.Type = tbType.Text; this.FormClosing -= FormKeyDetails_FormClosing; this.Close(); }
private void AddKey(KeyData keyData) { if (FormDetails.ItemDataManager.KeyData.ContainsKey(keyData.Name)) { DialogResult result = MessageBox.Show( keyData.Name + " already exists. Overwrite it?", "Existing key", MessageBoxButtons.YesNo); if (result == DialogResult.No) return; ItemDataManager.KeyData[keyData.Name] = keyData; FillListBox(); return; } ItemDataManager.KeyData.Add(keyData.Name, keyData); lbDetails.Items.Add(keyData); }
void btnCancel_Click(object sender, EventArgs e) { key = null; this.FormClosing -= FormKeyDetails_FormClosing; this.Close(); }