Visual FoxPro sample: Demonstrates the ListView ActiveX control (253457)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft Visual FoxPro 8.0
  • Microsoft Visual FoxPro 9.0 Professional Edition

This article was previously published under Q253457

SUMMARY

ListView.exe is a sample that illustrates the use of the properties and methods of the ActiveX ListView control in Visual FoxPro.

MORE INFORMATION

The following file is available for download from the Microsoft Download Center:
Release Date: Jul-07-2000

For more information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to obtain Microsoft support files from online services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.
Note There is a bug in the original release of this sample which prevents the LISTVIEW.SCX form from running in Visual FoxPro 7 - 9. When you run the form in those versions of VFP, you will receive the following error message in the BuildSelectedItemText() method of the form:
Error 107
Operator/operand type mismatch
The bug can be fixed by changing this line in that method:
"      ReportIcon:  " + loListSubItem.ReportIcon + CRLF + ;
to this:
"      ReportIcon:  " + IIF(ISNULL(loListSubItem.ReportIcon), "", loListSubItem.ReportIcon) + CRLF + ;
When you save and recompile the form, you may also receive an error message about a missing INCLUDE file. You may receive this message because the form was hard-code to include FOXPRO.H from the VFP6 default installation directory.

To resolve this problem, point the form designer Include File dialog to FOXPRO.H in the HOME() directory of your current VFP version when you are prompted.

The ListView.exe file contains the following files:
File nameSize
Readme.txt2865
ListView.pjt6105
ListView.pjx5743
ListView.sct69852
ListView.scx6265
Countrys.cdx3072
Countrys.dbf977
Customer.cdx15360
Customer.dbf25978
Ascend.bmp322
Descend.bmp322
Santa Fe Stucco.bmp65832
Vw-Dtls.bmp246
Vw-List.bmp246
Vw-Lrgic.bmp246
Vw-Smlic.bmp246
Flgargen.ico1078
Flgausta.ico1078
Flgbelg.ico1078
Flgbrazl.ico1078
Flgcan.ico1078
Flgden.ico1078
Flgfin.ico1078
Flgfran.ico1078
Flggerm.ico1078
Flgirel.ico1078
Flgitaly.ico1078
Flgmex.ico1078
Flgnorw.ico1078
Flgpolan.ico1078
Flgport.ico1078
Flgspain.ico1078
Flgswed.ico1078
Flgswitz.ico1078
Flguk.ico1078
Flgusa01.ico1078
Flgusa02.ico1078
Flgvenez.ico1078
Question.ico2158
The ListView control is an ActiveX control that provides a visual interface to display items in table form or in lists with an associated icon. Windows Explorer is an example of an application that uses a ListView control.

The ListView control uses two collections of objects, ListItems and ColumnHeaders, to store and display data. The ListItems collection contains ListItem objects. Each ListItem represents an individual item that can be displayed in the control. Each ColumnHeader represents a column of ListItem objects.

A ListItem has a label represented by the Text property and an icon represented by the Icon or SmallIcon properties. Additionally, a ListItem has a Selected property to indicate if a user selects the item. It also has a ListSubItems collection that you can use to add other information to the control.

This example contains a project (ListView) that contains one form (ListView), two tables, each with an index (.cdx) and a collection of bitmap (.bmp) and icon (.ico) files. The ListView form contains a ListView control and other controls that allow you to manipulate or view the properties of the ListView and also the currently selected list item in the ListView. There are Tooltips that help explain the purpose of the property that is being controlled or displayed. There are also three ImageList controls on the form. Both oleImageList1 and oleImageList2 contain icons for the ListView control to use. The icons for the "large icon" view are stored in oleImageList1. The icons for the "small icon" and "list" views are stored in oleImageList2. Both of these image lists are loaded with images through code in the form's Init event. Icons used on the Column Headings in the "detail/report" view are stored in oleImageList3. The images for oleImageList3 are loaded during design time.

When the form is executed, it loads information from the Customer table. It uses the Countrys table to find the name of the Icon file to use for that country. If a country cannot be found, it uses the default icon (Question.ico) and the Ghosted property of that ListItem is set to True. If the country is USA, the Bold properties of the ListItem and the ListSubItems are set to True and the ForeColor properties are set to Blue.

The default view of the ListView is the "large icon" view with the icons listed in company name order in ascending sequence. When the ListView is in "detail/report" view, you can click the column headings to set the sort order and sequence. The first click on a column heading sets it in ascending sequence; the second click sets it in descending sequence.

The ListView control does have a Picture property so you can set a wallpaper behind the ListItems. The Santa Fe Stucco bitmap file has been included so that you may try this feature out.

REFERENCES

For more information about the ListView control, see that topic in the Windows Controls Help file, CMCTL198.CHM, located where you have installed your MSDN Library.

For more information the ListView control, click the following article numbers to view the articles in the Microsoft Knowledge Base:

163803 BUG: Cannot set ImageList property of TreeView visually

192693 BUG: License error with ActiveX control added at run-time


Modification Type:MajorLast Reviewed:7/14/2005
Keywords:kbdownload kbCtrl kbfile kbhowto kbSample KB253457 kbAudDeveloper