|
|
|
|
|
- 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
Manipulating ListView controls programmatically
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 2025Selecting 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:
- 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 | Memory | Indicates if the specified ListView control is populated programmatically or is based on a data file. | ListViewMode | Sets the display mode of the ListView control (ListView, List Box and panorama modes). | Count | Gets the number of rows in a ListView control. | VerticalOrientation | Gets and sets the orientation of a ListView control. | FillType | Indicates how a ListView control is populated (programmatically, from a data file or from a variable). | DisplayedValue | Gets the value of the current row or the value of a specific row in the ListView control. | Empty | Indicates if a ListView control is empty. | ListView control populated programmatically only | Sorted | Indicates 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 | BrowsedFile | Gets and sets the data file or query used to display records in ListView controls. | AutoBrowse | Indicates if a ListView control is looped through automatically or programmatically. | DisplayedItem | Gets and sets the item that corresponds to the text displayed in a ListView control. | DisplayedItemImage | Gets and sets the item that corresponds to the image displayed in a ListView control. | StoredItem | Gets and sets the stored item of a ListView control. | BrowsedItem | Gets 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|