# Collections

Better ListView: Ultimate .NET ListView replacement control for WinForms (C#, VB.NET)
Download More Info

Better ListView contains several types collections of its elements (columns, items, sub-items, groups). These can be accessed via properties:

- Columns

- Items

- Groups

- BetterListViewItem.SubItems

- BetterListViewItem.ChildItems

Better ListView Express does not contain the BetterListViewItem.ChildItems collection as it does not support hierarchical items.

Each of these collections are of type BetterListViewElementCollection<TItem> where TItem is collection element type. All these collection also implement IList<TItem>, ICollection<TItem> and their nongeneric companions.

They also implement extra functionality through IExtendedList<TItem>:

- AddRange

  - add set of items

- RemoveRange

  - remove subset of items

These collections are bound to Better ListView, so any modification to these collection will be projected into control state.

When the collection is created by user code, e.g.:

C#

    var myItems = new BetterListViewItemCollection();

Visual Basic

    Dim myItems = New BetterListViewItemCollection()

then the collection is not bound to the control and its state is independent on the control's state.

All the collections are both binary and XML serializable.

## Adding Elements

Specific collections provide several overrides for easy addition of items, for example:

C#

    myItems.Add("New Item");

Visual Basic

    myItems.Add("New Item")

Adds new item with text 'New Item' in the collection.

All Better ListView collections support adding arbitrary objects, for example:

C#

    var person = new Person("Mark Bradley", 13, Gender.Male);

    myItems.Add(person);

Visual Basic

    Dim person = New Person("Mark Bradley", 13, Gender.Male)

    myItems.Add(person)

This will create a new BetterListViewItem with Text property obtained from converting the Person object. The type can either provide custom TypeConverter, or default TypeConverter (for primive types) or ToString method is used for conversion.

Multiple custom items can be added either:

C#

    myItems.AddRange(new object[] { person1, person2, "New Person" });

Visual Basic

    myItems.AddRange(New Object() {person1, person2, "New Person"})

Better ListView: Ultimate .NET ListView replacement control for WinForms (C#, VB.NET)
Download More Info