ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Developing an application or website / Controls, windows and pages / Controls: Available types / ListView control
  • Overview
  • Initializing a ListView control
  • Assigning a value to an element
  • Populating a ListView control
  • Selecting an element in a ListView control
  • Selecting an element at row
  • Setting the position on the last element of the ListView control
  • Retrieve item selected in List Box control
  • Retrieving the index of the selected element
  • Getting the value of the selected element
  • Properties specific to ListView controls
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
WINDEV allows you to programmatically manipulate ListView controls. Simply use the variable the of the ListView control in the code. This variable is of type numeric.
The variable of the ListView control:
  • corresponds to the name of the ListView control.
  • is initialized with the index of the element selected in the ListView control.
Note: To manipulate an item in a ListView control to which no memorized item is associated, simply use the following notation:
<ListView control> [ <Element index>]
Initializing a ListView control

Assigning a value to an element

To initialize an element found in a ListView control, use ListAdd.
ListAdd(LSV_ListView1, "Sun", "C:\IMG\Sun.JPG")
ListAdd(LSV_ListView1, Photo)

Populating a ListView control

To initialize a ListView control, an iteration loop must be used to initialize all control elements.
Index is int
FOR Index = <Start position> TO <End position>
ListAdd(<ListView control>, <Value>, <Image>)
END
i is int
FOR i = 1 TO 52
ListAdd(LSV_ListView1, NAME[i], Image[i])
END
New in version 2025
WINDEV The LoadImageProcedureList function can be used to define a WLanguage procedure to be called when displaying the lines in the list. This procedure allows you to use dynamic images (not necessarily stored on disk).
Selecting an element in a ListView control

Selecting an element at row <Index>

To select the element at row <Index>, use:
  • direct assignment:
    <ListView control> = Index
  • the ListSelectPlus function:
    ListSelectPlus(<ListView control>, <Index>)

Setting the position on the last element of the ListView control

To position on the last element of a ListView control, use:
  • Count:
    <ListView control>.Count
  • ListSelectPlus associated with the Count property:
    ListSelectPlus(<ListView control>, <ListView control>.Count)
  • the ListCount function:
    ListCount(<ListView control>)
Retrieve item selected in List Box control

Retrieving the index of the selected element

To retrieve the index of the selected element, use one of the following syntaxes:
  • the element directly:
    Index = <ListView control>
  • the ListSelect function:
    Index = ListSelect(<ListView control>)
Remark: For multi-selection ListView controls, the ListSelect function retrieves the selected items..
// Retrieve the elements of a multi-selection ListView control
Rank is int = 0  // selection number
Index is int = 0  // index of the selected element
LOOP
Rank = Rank + 1
Index = ListSelect(LSV_ListView1, Rank)
IF Index = - 1 THEN BREAK
END

Getting the value of the selected element

To retrieve the value of selected element, use one of the following syntaxes:
  • Syntax 1:
    Index is int = <ListView control>
    <Variable> = <ListView control>[Index]
  • Syntax 2:
    <Variable> = <ListView control>[<ListView control>]
  • Syntax 3: Property DisplayedValue
    <Variable> = <ListView control>.DisplayedValue

    Warning The value stored during programming may differ from the value displayed. To get the stored value corresponding to one of the rows in the ListView control, use the StoredValue property.
Properties specific to ListView controls
The following properties are specific to ListView controls:
All types of ListView controls
MemoryIndicates if the specified ListView control is populated programmatically or is based on a data file.
ListViewModeSets the display mode of the ListView control (ListView, List Box and panorama modes).
CountGets the number of rows in a ListView control.
VerticalOrientationGets and sets the orientation of a ListView control.
FillTypeIndicates how a ListView control is populated (programmatically, from a data file or from a variable).
DisplayedValueGets the value of the current row or the value of a specific row in the ListView control.
EmptyIndicates if a ListView control is empty.
ListView control populated programmatically only
SortedIndicates if a ListView control populated programmatically is sorted or sorts a ListView control (sort based on the labels of the elements).
ListView control based on a data file only
BrowsedFileGets and sets the data file or query used to display records in ListView controls.
AutoBrowseIndicates if a ListView control is looped through automatically or programmatically.
DisplayedItemGets and sets the item that corresponds to the text displayed in a ListView control.
DisplayedItemImageGets and sets the item that corresponds to the image displayed in a ListView control.
StoredItemGets and sets the stored item of a ListView control.
BrowsedItemGets and sets the item used to automatically loop through ListView controls.

For a complete list of WLanguage properties that can be used with ListView controls, see ListView control properties.
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 11/01/2024

Send a report | Local help