I have a radio button and a listbox. After clicking on the radiobutton, a collection of items will be added into the listbox. I'm trying to go back to the collection I've started working on to edit a System.Collections.Specialized.StringCollection, but after running the program, the list of items has not updated. How would I fix this?

Here is the code I have:

Private Sub RB_Teacher_1_CheckedChanged(sender As Object, e As EventArgs) Handles RB_Teacher_1.CheckedChanged

        'Displays Teacher Colleciton
        If RB_Teacher_1.Checked = True Then

            'Clearazation of all previous items
            For Each item As String In My.Settings.TeacherCollection
                ListBox1.Items.Remove(item)
            Next

            'Initialization of the required component informaiton
            For Each item As String In My.Settings.TeacherCollection
                ListBox1.Items.Add(item)
            Next

        End If

    End Sub

Hi,

I don't see where you are removing items from your collection. I only see you adding and removing from your listbox.

I go to project properties, and in the settings, where I have the collection, I go there to add more items manually, but the changes won't save unless after editing the collection, I change the name of the collection, close out of the properties, with a message "Do you want to save changes" or something like that. That way, the collection updates with the edits I've made, so the next time I add the collection to the listbox, my changes I've done previously to the items are shown in the listbox. I couldn't figure out any other ways to save the changes made to the collection in the settings tab of the project properties.

This article has been dead for over six months. Start a new discussion instead.