vbAccelerator ListView Control

Use the latest ListView features

ListView Control

This control provides an alternative to the VB ListView control and adds support for almost all of the new ComCtl32.DLL v6.0 features that are missing from the VB version: ListView grouping, Tile view with configurable sub-items, Multiple Work Areas and more.

ListView Control Features

The ListView control object model is shown below:

ListView Object Model

Here's a brief tour of features of these objects:

The Control

The vbalListViewCtl control provides access to the various object collections, raises events and also lets you configure the visual properties of the control. Most of these are standard, however some notable features are:

  • View property supports Tile mode.
  • ImageList property allows you to associate up to five image lists with the control: Tile, Large Icon, Small Icon, Header and State images. If you don't specify a Tile ImageList then the LargeIcon image list is used. Please note that MSCOMCTL.OCX (VB6 Windows Common Controls) ImageLists are not supported as the hImageList handle returned by this object is incorrect. This may be resolved in the future by an update from Microsoft (see KB).

cListItem

The cListItem object allows you to configure ListItems. Notable features are that you can add items to groups using the Group method.

cSubItem

The cSubItem object lets you configure the subitem text and image, and whether it displays in the Tile View using the ShowInTile property. When adding subitems to a tile, the items are displayed in the order that the ShowInTile property is called, and the number of items that are actually shown is configured using the control's TileViewItemLines property (whether everything is displayed depends on the available size of the tile).

cItemGroup

The cItemGroup allows you to configure groups added to the ListView. Once you've added a group you can specify whether it should be a Header or a Footer by using the GroupType property, specify the text alignment using the Align property and check whether the group is displayed or collapsed using the State property. Note when using groups that you can specify whether groups are enabled or disabled using the Enabled property of the cItemGroups collection and that if groups are enabled, only those items which have been added to groups are displayed.

cWorkArea

ListView work areas allow you to create multiple regions in the ListView for grouping objects together. Once you've added a WorkArea, you can move an item into it either by dragging or by using the ListItems Left and Top properties to place it in the region. Note WorkAreas do not clip the ListItems within them. This means that if you place too many items into an area for the size of the region, they just spill out off the bottom of the WorkArea.

Linking to ComCtl32.DLL v6.0

If you want to use new features like Tile View and Grouping then you will need to link your application to ComCtl32.DLL v6.0 using a Manifest. This is described in the articles Using Visual Styles and Making Visual Styles apply at design and debug-time. Note that ComCtl32.DLL is only available on Windows XP or above.

Important If you are running on a pre-XP system, then you will need to wrap calls to the Groups collection in an error handler, since this object will return Nothing.

EOE

There are a few omissions with the control at this point which are still being researched:

  • State Icon Images not supported.
  • Should be able to automatically create group headers in a sorted ListView.
  • Insertion point marker in an AutoArrange ListView not displayed during dragging.
  • Dragging multiple items in a multi-select ListView is not supported.
  • Automatic drag-drop mode not automatic.
  • Text is currently set using ANSI APIs
  • Owner Custom-Draw of items is not provided for.