It all works fine...up to one point.
The ArrayList is dynamic, which means the contents of it change, during the course of program use.
But instead of Updating the ListBox, virtually nothing happens. The items that were written into the ListBox during the first run remain inside the ListBox, assuming the new values of the ArrayList. Obviously, if the new ArrayList is shorter than the original List, a click on an basically obsolete makes the program crash, since it is an unreferenced object.
This code is used to change the items:
Expand|Select|Wrap|Line Numbers
- AL.Clear(); //Empties the ArrayList, fresh start
- while(DataAvailable) //Reads data from an external source
- AL.Add(new ALList(name, content)); // Adds a custom class to the ArrayList, consisting of a name and a content.
- ListBox.DataSource = AL; //Sets the DataSource to ArrayList.
- ListBox.DisplayMember = "Display"; //Chooses the name from the custom class
- ListBox.ValueMember = "Content"; //Sets the Value to the Content.
Expand|Select|Wrap|Line Numbers
- ListBox.DataSource = null; //Frees the DataSource, Items become accessible again
- ListBox.Items.Clear(); //Empties the ListBox by Force.
- ListBox.DataSource = AL; //Assigns the DataSource AL to the LB again.
I've run out of ideas and would like to ask for your expertise now.