private void btnAddTelephone_Click(object sender, EventArgs e) { using (AddTelNumber f = new AddTelNumber()) { f.StartPosition = FormStartPosition.Manual; Point p = btnAddTelephone.PointToScreen(btnAddTelephone.Location); p.Y -= this.Height; f.Location = p; if (f.ShowDialog() == DialogResult.OK && !String.IsNullOrWhiteSpace(f.number) && !lstTelephones.Items.Cast <string>().ToList().Contains(f.number)) { lstTelephones.Items.Add(f.number); } } }
private void btnAddTelephone_Click(object sender, EventArgs e) { using (AddTelNumber f = new AddTelNumber()) { f.StartPosition = FormStartPosition.Manual; Point p = btnAddTelephone.PointToScreen(btnAddTelephone.Location); p.Y -= this.Height; f.Location = p; if (f.ShowDialog() == DialogResult.OK && !String.IsNullOrWhiteSpace(f.number) && !lstTelephones.Items.Cast <ITelephone>().Select(t => t.TelephoneNumber).ToList().Contains(f.number)) { ITelephone tel = entityFactory.NewTelephone(); tel.TelephoneNumber = f.number; lstTelephones.Items.Add(tel); lstTelephones.SelectedItem = tel; } } }