Visual Basic: Windows Controls
- A ColumnHeader object is an item in a ListView control that contains heading text.
- A ColumnHeaders collection contains one or more ColumnHeader objects.
The syntax lines above refer to the collection and to individual elements in the collection, respectively, according to the standard collection syntax.
The ColumnHeader object, ColumnHeaders collection syntax has these parts:
|listview||An object expression that evaluates to a ListView control.|
|index||Either an integer or string that uniquely identifies a member of an object collection. An integer would be the value of the Index property; a string would be the value of the Key property.|
You can view ColumnHeader objects in Report view only.
You can add ColumnHeader objects to a ListView control at both design time and run time.
With a ColumnHeader object, a user can:
- Click it to trigger the ColumnClick event and sort the items based on that data item.
- Grab the object's right border and drag it to adjust the width of the column.
- Hide ColumnHeader objects in Report view.
There is always one column in the ListView control, which is Column 1. This column contains the actual ListItem objects; not their subitems. The second column (Column 2) contains subitems. Therefore, you always have one more ColumnHeader object than subitems and the ListItem object's SubItems property is a 1-based array of size
The number of ColumnHeader objects determines the number of subitems each ListItem object in the control can have. When you delete a ColumnHeader object, all of the subitems associated with the column are also deleted, and each ListItem object's subitem array shifts to update the indices of the ColumnHeader, causing the remaining column headers' SubItemIndex properties to change.