private void btnEdit_Click(object sender, EventArgs e) { if (lstButtons.SelectedIndex < 0) { return; } var frm = new AutoCompleteExpressionBoxCustomizationEdit(); frm.Payload.KVP = GetKVP(lstButtons.SelectedItem as string); if (frm.ShowDialog() == DialogResult.OK) { var key = "D" + frm.Payload.KVP.Value.Key; if (lstButtons.Items.Cast <string>().Any( w => string.Compare(w, 0, key + " ", 0, key.Length + 1) == 0)) { MessageBox.Show("Duplicate entry detected, dropping the new one.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { lstButtons.Items[lstButtons.SelectedIndex] = key + " = " + frm.Payload.KVP.Value.Value; } } }
private void btnAddNew_Click(object sender, EventArgs e) { var frm = new AutoCompleteExpressionBoxCustomizationEdit(); if (frm.ShowDialog() == DialogResult.OK) { string key = "D" + frm.Payload.KVP.Value.Key; if (lstButtons.Items.Cast<string>().Any( w => string.Compare(w, 0, key + " ", 0, key.Length + 1) == 0)) { MessageBox.Show("Duplicate entry detected, dropping the new one.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { lstButtons.Items.Add(key + " = " + frm.Payload.KVP.Value.Value); } } }