This solution demonstrates the usage of the new System.Collections.CollectionBase class for creating a strongly-typed collection.
This sample uses two classes: Customer and Customers. Customers inherits from System.Collections.CollectionBase in order to create a type safe collection to manage multiple customer instances. The CollectionBase class exposes an InnerList instance which is used to store Customer instance references.
The Customers class exposes overloaded versions of Add, Item, and Remove to facilitate management of the Customer instances. Unlike earlier versions of Visual Basic where optional parameters might have been used, overloaded members provide a more type safe way of accessing and managing a collection of internal types.
See the comments in the source code for more information.
Requires the Trial or Release version of Visual Studio .NET Professional (or greater).
Enter some data for the first name, last name, and account number in the three text boxes on the main form and click the Add button. This will add a Customer object to the Customers collection with the data you specified. The account number for each customer added to the collection will appear in the listbox. After there is at least one Customer in the collection, you can select it in the listbox. Then you can remove it from the collection or show the details of a particular Customer in the collection. You can also click "Reload from collection" to clear the listbox and reload each item in the collection into the listbox.