- 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
Handling ListView controls programmatically
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:
- 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 | 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 a ListView control, see Properties associated with ListView controls.
|
|
|
|