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

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.