ListView Control
The listview control displays information in a tabular form - rows and columns. Four ways to view the data are provided - small icon, icon, report, list.

Report Modes
As shown in the examples above, the ListView control provides four different ways of viewing information. The different modes are:

Arguments
The Control Add statement is used to create all new controls. Here are the statement's arguments and any special significance to the listview control.

Usage Notes
Some of these comments refer to the ListView-specific statement in the next section below.

The ListView is limited to 32,767 items.

Indexing is starts at 1 for all Control and listview statements.

The value format& describes the format and justification of the text: 0=left, 1=right, 2=center. Column 1 is always left-justified,

ListView-Specific PowerBASIC Statements
PowerBASIC provides several statements specific to the listview control. These allow the application to manage the content and display of the control.

Here's a summary of the ListView statements, categorized by the capability they provide.

And here's a description and syntax for each of the LISTVIEW statements, along with some additional usage information.

The ListView-specific styleXX values are:

See the Usage section above for information on how to use the values made available by these statements.

Messages, Notifications, Styles, and ExtSstyles
There are four types of named constants in the following table. All are pulled from the MSDN web site.

The table below does not include the StyleXX values listed above in the discussion on ListView-specific statements.

The first column contains control-specific named constants and the second column contains generic window named constants (listview controls are windows).

Also, if the PowerBASIC Help file has an entry on the value, it is highlighted in yellow. If the value was noted in PowerBASIC Help as a default value, it is also shown in bold text.

In the values for notifications, descriptions starting with -n and -c refer to events received through the %wm_notify and %wm_command messages. By default, PowerBASIC controls can receive both of these messages.

   

And here is a short description of many of the named constants corresponding to notifications, styles, and extstyle - particularly those discussed in the PowerBASIC Help topics.

    %lvs_alignleft           - left align list
    %lvs_aligntop            - align with top
    %lvs_autoarrange         - icons are auto-arranged
    %lvs_editlabels          - allow text edit
    %lvs_icon                - set icon view
    %lvs_list                - set list view
    %lvs_nocolumnheader      - use no column headers in report view
    %lvs_nolabelwrap         - do not wrap
    %lvs_noscroll            - do not display scrollbars
    %lvs_nosortheader        - no column sort. flat view.
    %lvs_ownerdata           - specifies virtual listview control
    %lvs_ownerdrawfixed      - owner window can paint items in report view
    %lvs_report              - report view, left align 1st column, headers
    %lvs_shareimagelists     - imagelist remains if listview destroyed
    %lvs_showselalways       - show selection if focus is lost
    %lvs_singlesel           - allow select of only one item
    %lvs_smallicon           - small icon view
    %lvs_sortascending       - sort indexes in ascending order
    %lvs_sortdescending      - sort indexes in descending order
    %ws_disabled             - initially disabled (no user input)
    %ws_ex_clientedge        - apply sunken edge border
    %ws_ex_left              - generic left-aligned properties
    %ws_ex_right             - generic right-aligned properties
    %ws_ex_staticedge        - apply 3D border
    %ws_ex_transparent       - draw controls/windows beneath control first
    %ws_ex_windowedge        - apply raised edge border
    %ws_group                - starts/ends group. use %ws_tabstop style.
    %ws_tabstop              - allows receipt of keyboard focus

Callback Function
A control can have its own callback function, or use the parent dialog callback function.

A control callback function should return TRUE to indicate it has processed the message. This prevents unnecessarily calling the dialog callback function, which will process the message if no control callback function is available, or if the control callback function returns FALSE.

By default, both %WM_COMMAND and %WM_NOTIFY messages are received. However, if the #MESSAGE COMMAND compiler directive is invoked, the %WM_NOTIFY messages will not be available.

Here's a sample listview control callback function.

   CallBack Function cbListView()
      Select Case CB.MSG
         Case %WM_COMMAND
            Select Case CB.CTLMSG
               Case %lvn_columnclick
               Case %lvn_deleteitem
               Case %lvn_endlabeledit
               Case %lvn_insertitem
               Case %lvn_itemactivate
               Case %lvn_itemchanged
               Case %lvn_itemchanging
               Case %lvn_keydown
               Case %nm_click
               Case %nm_dblclk
               Case %nm_killfocus
               Case %nm_rclick
               Case %nm_rdblclk
               Case %nm_return
               Case %nm_setfocus
         End Select
      End Select
   End Function

In each Case section, add the statements the application needs to respond to the event. Also, be sure to add "Function=1" as appropriate to indicate that the event was handled by the callback function.

Issues
Help mentions that listview can contain images, but no information is provided on how to add the images. There are two samples apps distributed with PowerBASIC but with little explanation.

I'll update this page as more information becomes available.

CONTROL Statement Syntax
The following table lists the various Control statements (except the ADD statements). Most, but not all, can be used with the listview control. A one-line description of the statement and then its syntax are presented.

If you have any suggestions or corrections, please let me know.