How to get a list box to disallow duplicate items (C#)

private void button1_Click(object sender, EventArgs e)
{
if (!ListBox.Items.Contains(listBox1.SelectedItem)) // Random Idea which doesnt work
{
listBox2.Items.Add(listBox1.SelectedItem);
}
}

ref: http://stackoverflow.com/questions/11041802/how-to-get-a-list-box-to-disallow-duplicate-items/11041896?stw=2#11041896

Published by

sornram9254

Ayutthaya Technical College/Voc.Cert.🛠️ | KMUTNB/B.S.Tech.Ed.⚙️ | Information Security Engineer 👨🏻‍💻| Penetration Tester👨🏻‍💻 | COYG🔴 Milan🔴⚫️ | Taylor Swift👩‍🎤 | ติ่งซีรีส์ญี่ปุ่น 🇯🇵

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.