Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 4

View Property of ListView Control in Visual Basic 6

The overall appearance of a ListView is determined by the View property. The View property can have one of the following four values:
  • lvwIcon (0) Display item text along with the regular icon with one or more ListItems per line.

  • lvwSmallIcon (1) Display item text along with the small icon with one or more ListItems per line.

  • lvwList (2) Display the small icon with the text to the right of the icon. One ListItem will appear per line.

  • lvwReport (3) Display the small icon with the text to the right of the icon and sub-item information to the right of the text displayed in columns. One ListItem will appear per line.

ListView Control - Add and Remove Methods

ListItems are inserted into a ListView by using the Add method.

The Add method has the following syntax:

ListView1.ListItems.Add(index, key, text, icon, smallIcon)

All the arguments for the Add method are optional.

The Index argument is an integer value that you can use to specify the position of the new item being added to the list. If the Index argument is omitted, Visual Basic places the new item at the end of the list.

The Key property is a unique string that you can use to identify an item in the list instead of using the Index to that object.

The last three arguments—Text, Icon, and SmallIcon—determine the appearance of the new item in the ListView.

If the Text argument is given, that text will appear with the item in the ListView.

The Icon and SmallIcon arguments are integers referring to an icon in an ImageList control. As with the TreeView, the ListView needs at least one ImageList control on the form for icons to be displayed.

References to ImageLists are set through the Property Pages dialog box for the ListView, as shown in Figure 4.8. You can set references to two different ImageLists for a ListView: one reference for regular icons (when the ListView's View property is lvwIcon) and a second list for small icons (when the View property is set to any other value).

Because an ImageList control can only contain images of a single size, two ImageLists are required if you will be using both regular and small icons. Typically regular icons will be 32X32, and small icons will be 16X16.

Setting an ImageList reference for a ListView control.
FIGURE 4.8 Setting an ImageList reference for a ListView control.

ListView Control topics


  

.<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved