Appearance

The colors, the border and the background picture of a ListView, and the look of the lists of Windows Explorer.

With ListView1
    .BorderStyle = CCBorderStyleSingle
    .VisualTheme = LvwVisualThemeExplorer     ' the selection and hot items of Windows Explorer
    .BackColor = RGB(250, 250, 245)
    .ForeColor = vbBlack
End With

Colors

BackColor fills the control behind the items, and ForeColor is the color of the texts. An item and a subitem can have a ForeColor of their own, and be Bold; ResetForeColors takes their colors away again. The background of the texts is that of the control unless TextBackground makes it BackColor, and ItemBkColor gives a row a color of its own.

A background picture

Picture is drawn behind the items, at the corner or the middle that PictureAlignment names, or repeated over the whole control. With PictureWatermark True it is a watermark instead, at the bottom right corner. A picture needs visual styles.

A picture that is not a watermark is drawn better without double buffering, so assigning one sets DoubleBuffer to False. A watermark sets it to True again.

Set ListView1.Picture = LoadPicture(App.Path & "\paper.bmp")
ListView1.PictureAlignment = LvwPictureAlignmentTile
ListView1.TextBackground = CCBackStyleTransparent     ' the picture shows behind the texts

Properties

BackColor

The color behind the items. OLE_COLOR. Default: vbWindowBackground.

-1, which stands for no color, raises run-time error 380.

BorderStyle

The border of the control. A member of CCBorderStyleConstants. Default: CCBorderStyleSunken. Another value raises run-time error 380.

DoubleBuffer

Whether the control draws its items in memory first and then copies them to the screen at once, which keeps them from flickering. Boolean. Default: True. It has an effect when the program has visual styles. Picture changes it; see A background picture.

ForeColor

The color of the texts of the items and the subitems that have no color of their own. OLE_COLOR. Default: vbWindowText.

Picture

The picture drawn behind the items. A picture object, or Nothing (the default) for none. A bitmap is drawn as it is; an icon, on BackColor. Assigned with Set.

PictureAlignment

Where Picture is drawn. A member of LvwPictureAlignmentConstants. Default: LvwPictureAlignmentTopLeft. Another value raises run-time error 380. While the picture is tiled, no column is shaded as the SelectedColumn.

PictureWatermark

Whether Picture is a watermark, drawn at the bottom right corner whatever PictureAlignment says. Boolean. Default: False.

TextBackground

What is behind the texts of the items. A member of CCBackStyleConstants: CCBackStyleTransparent (the default), with which the background or the picture shows behind them, or CCBackStyleOpaque, with which the texts are on BackColor. Another value raises run-time error 380.

VisualTheme

Whether the control is drawn as the list views of Windows Explorer are. A member of LvwVisualThemeConstants. Default: LvwVisualThemeStandard. Another value raises run-time error 380. It has an effect while the program has visual styles and VisualStyles is True.

LvwPictureAlignmentConstants

The values of PictureAlignment.

Member Value Description
LvwPictureAlignmentTopLeft 0 At the top left corner.
LvwPictureAlignmentTopRight 1 At the top right corner.
LvwPictureAlignmentBottomLeft 2 At the bottom left corner.
LvwPictureAlignmentBottomRight 3 At the bottom right corner.
LvwPictureAlignmentCenter 4 In the middle.
LvwPictureAlignmentTile 5 Repeated over the whole control, under the header in the report view.

LvwVisualThemeConstants

The values of VisualTheme.

Member Value Description
LvwVisualThemeStandard 0 The visual style of the list view of Windows.
LvwVisualThemeExplorer 1 The visual style of the lists of Windows Explorer, with their colors for the selected and the hot items.

See Also

  • ListView control
  • Common members – Font, VisualStyles and the enumerations of the border and the background