C# ListBox Help

When adding items to a listbox, how can I make it so it does not allow a user to add the same item more than once.

I am programming a registration system for class, there is a screen with two listboxes, the first listbox is the available courses a user can register for and the second listbox is the courses that he/she has registered for. as of now they can register for the same course as many times as they would like, how can I stop that from happening.

The program basically takes an item from the first listbox and puts it in the second listbox.

hopefully that makes sense.

       if (CISYcoursesListBox.SelectedIndex != -1)
        {
            {
                string result;
                result = CISYcoursesListBox.SelectedItem.ToString();
                const int SIZE = 4;
                string[] course = new string[SIZE];

                course[0] = result;
                CISYresultListBox.Items.Add(result);

            }

EDIT: http://imgur.com/zLqkp A Picture of the form

Posted Dec 2, 2011, 1:49 AM UTC · edited

34
Loading comments…