VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering

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

Icon and SmallIcon Properties of ListView Control in Visual Basic 6

After ListItems have been added to a ListView, their references to icons in an ImageList can be read or set through the Icon and SmallIcon properties. These properties have integer values that correspond to the index value of images in the ImageLists to which the ListView is bound. If you create a form with ListView1, ImageList1, and ImageList2 controls, for example, and you use ImageList1 for regular icons and ImageList2 for small icons, the following:

x = ListView1.ListItems(1).Icon

returns an integer that corresponds to an index value of an image in ImageList1 while:

x = ListView1.ListItems(1).SmallIcon

gives you the index of an image in ImageList2.

FindItem Method of ListView Control

After items have been added to a list, you may have a need to find one or more of those items. The FindItem method of the ListView control enables you to search through the items and return the desired ListItem object. FindItem has the following syntax:

ListView1.FindItem (string, value, index, match)

The string argument, which is required, specifies the string for which you are searching in the list. The value argument tells Visual Basic how to search for the string. Value can be one of the following:

  • lvwText (0) Search for the String argument in the Text property of the ListItems.

  • lvwSubItem (1) Search for the String argument in the sub-items of the ListItems.

  • lvwTag (2) Search for the String argument in the Tag property of the ListItems.

The Index argument can be used to indicate the start position for the search. This argument can have either an integer or a string value. If the value is an integer, Visual Basic starts the search at the ListItem with an Index of that value. If the argument is a string, the search begins at the item having the same Key value as the argument value. If the Index argument is not specified, the search starts at the first item in the list.

The final argument, match, determines how Visual Basic will select a ListItem that matches the string argument. Match can have the following two values:

  • lvwWholeWord (0) A match occurs if the String argument matches the whole word that starts the Text property of the item.

  • lvwPartial (1) A match occurs if the String argument matches the beginning of the Text property regardless of whether it is the whole word.

ListView Control topics


.<< Previous | Contents | Next >>

Home | Link to Us | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved