ListView Sample Applications

 

The following sample applications are included when you purchase the Visual Basic 6 Tutorial Download Package or the Visual Basic 6 "Extra" Sample Applications from The VB Programmer.

 

1. Views Example

This is a simple example that demonstrates the four settings for the View property. A toolbar with icons for the four views sits at the top of the screen. When the user clicks one of the toolbar buttons, the appearance of the ListView changes to the appropriate View. Screenshots of two of the four views are shown below.

 

 

 

2. Daily Menu Planner

This is an enhancement of the Daily Menu Planner sample application that was presented as an programming exercise using ListBoxes. In this application, as the user makes food choices for each meal, a running subtotal of the food statistics (calories, fat, carbohydrates, protein, and cholesterol) is presented in the Summary section on the lower half of the screen.

 

 

3. File ListView

This is an enhancement of the Text File Viewer sample application presented in the topic on the file system controls (DriveListbox, DirListBox, and FileListBox). In this application, the FileListBox is replaced by a ListView that shows the details for each file in the selected folder as well as the appropriate file icon.

 

 

4. Make "Row X" the Top Row of a ListView

It is sometimes desired to make a particular row the topmost row in a ListView. Unfortunately, there is no obvious way to do this, as the ListView lacks a property like the ListBox's TopIndex property or the MSFlexGrid's TopRow property. This example shows how it can be done.

 

 

 

 

5. How to detect what "cell" the user clicked on in a ListView

There is no obvious way to detect what "cell" a user clicked on (i.e., what SubItem within a ListItem) in a Report-style ListView. This example shows how it can be done.

 

 

 

6. Editable ListView

 

The ListView does not allow the user to edit data within its cells (with the exception of setting the "LabelEdit" property to "Automatic" but that affects the first item only you certainly cannot edit any SubItems). This example shows how you can use the technique of using a "floating" control (TextBox, ComboBox, or DTPicker in this example) to edit any cell of the ListView.

 

The screen-shots below show the editing of a text field, drop-down option field, and date field respectively.