ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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
  • Retrieving the element selected in the ListView control
  • Retrieving the index of the selected element
  • Getting the value of the selected element
  • Properties specific to ListView controls
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
WINDEV allows you to programmatically handle 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.
Remark: To handle a ListView element not associated with any stored item, use the following syntax:
<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
Selecting an element in a ListView control

Selecting an element at row <Index>

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

Setting the position on the last element of the ListView control

To set the position on the last element of the ListView control, use:
  • the Count property:
    <ListView control>.Count
  • ListSelectPlus associated with the Count property:
    ListSelectPlus(<ListView control>, <ListView control>.Count)
  • the ListCount function:
    ListCount(<ListView control>)
Retrieving the element selected in the ListView control

Retrieving the index of the selected element

To get the index of the selected element, use:
  • the element directly:
    Index = <ListView control>
  • the ListSelect function:
    Index = ListSelect(<ListView control>)
Remark: For multi-selection ListView controls, ListSelect is used to retrieve the selected elements.
// 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 get the value of the 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: DisplayedValue property
    <Variable> = <ListView control>.DisplayedValue

    Caution: The stored value can be different from the displayed value. 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 a ListView control, see Properties associated with ListView controls.
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 01/23/2023

Send a report | Local help