Sub-items

Every item within the list view can contain sub-items. These can be accessed using BetterListViewItem.SubItems collection.

Sub-items are displayed only in the Details view when the columns are present. Each item can have any number of sub-items, but the number of sub-items displayed is limited by the number of column headers.

The following screenshot shows Better ListView with items and sub-items displayed on the right of each items (in columns) with one sub-item being focused (see Focusing Elements for more information):

Sub-item Visibility

Sub-item visibility depends on current view and column headers.

In Details view, every column header has a corresponding sub-item. If all column headers are visible, sub-item indices (BetterListViewSubItem.Index) corresponding to their display order. When individual column headers are hidden, the corresponding sub-items are hidden as well. The display order can be retrieved using BetterListViewSubItem.DisplayIndex property in the same way as BetterListViewColumnHeader.DisplayIndex property. Of course, sub-items with higher display index than the display index of the last column are hidden.

In Tile view, image and label of the first sub-item is displayed along with labels of the other sub-items.

In other views, only the first sub-item is visible.

Copying sub-items

The sub-item collection behaves differently than other collections present in Better ListView.

It always have to contain at least one sub-item. Even if you call Clear method, one sub-item remains in the collection. This is because this sub-item represents properties of the item itself.

To copy sub-items from one item to another, you have to consider setting the first sub-item, while adding the other:

C#

itemTarget.SubItems[0] = (BetterListViewSubItem)itemSource.SubItems[0].Clone();

for (int indexSubItem = 1; indexSubItem < itemSource.SubItems.Count; indexSubItem++)
{
  itemTarget.SubItems.Add((BetterListViewSubItem)itemSource.SubItems[indexSubItem].Clone());
}

Visual Basic

itemTarget.SubItems(0) = DirectCast(itemSource.SubItems(0).Clone(), BetterListViewSubItem)

For indexSubItem As Integer = 1 To itemSource.SubItems.Count - 1
  itemTarget.SubItems.Add(DirectCast(itemSource.SubItems(indexSubItem).Clone(), BetterListViewSubItem))
Next