ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / List Box functions
  • Type of search
  • parameter
  • Uppercase/Lowercase characters
  • Seeking and selecting an element in a List Box or Combo Box control
  • Seeking an element in a List Box or Combo Box control based on a data file: search on the stored value or on the displayed value
  • Search and selection in a List Box control
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
Seeks an element in a List Box control (standard list box or listview) or in a Combo Box control (including the values described by gStoredValue).
Remark: <List Box>.Seek can be used on:
  • List Box controls based on a data file or populated programmatically,
  • single-selection or multi-selection List Box controls.
Example
// Find the element "Moore" in the List Box control "LIST_CustomerList"
ResSeek = LIST_CustomerList.Seek("Moore")
Universal Windows 10 AppAndroid
// Find "Moore" in the "LIST_CustomerList" List Box control based on a data file
// Exact-match search from element 5
ResSeek = LIST_CustomerList.Seek("Moore", True, 5)
Syntax
<Result> = <List Box control>.Seek(<Search element> [, <Type of search> [, <Start of search>]])
<Result>: Integer
  • Index of the element found.
  • -1 if no element corresponds to the search.
The element found is not selected. To select the element found, use <List Box>.SelectPlus.
<List Box control>: Control name
Name of List Box (or Combo Box) control to use.
<Search element>: Character string
Element to find in the specified List Box (or Combo Box) control.
<Type of search>: Optional boolean
  • True (default value) for an exact-match search,
  • False for a generic search.
<Start of search>: Optional integer
Index from which the search will start in the List Box or Combo Box control.
If this parameter is not specified, the search is performed in the entire control. This parameter is ignored for controls handled programmatically.
Remarks

Type of search

  • Exact-match search:
    The elements whose value is strictly equal to <Search element> are returned by <List Box>.Seek. For example:
    // Return all the customers named "Doe" found in "LIST_Name"
    LIST_Name.Seek("Doe")
  • Generic search:
    The elements starting with <Search element> are returned by <List Box>.Seek. For example:
    // Return all customers whose name starts with "SMI"
    LIST_Name.Seek("SMI", False)

<Start of search> parameter

The <Start of search> parameter is used to find all the occurrences of a string in a List Box or Combo Box control.
For example, to count the number of names starting with "SMI" in the "LIST_CustomerList" control:
Index is int
Cnt is int = 0
// Position on the first corresponding element
Subscript = LIST_CustomerList.Seek("SMI", False)
WHILE Index <> -1
Cnt++
// Find the next name starting with "SMI"
Subscript = LIST_CustomerList.Seek("SMI", False, Subscript + 1)
END
Universal Windows 10 AppAndroidiPhone/iPad

Uppercase/Lowercase characters

  • If the control is a List Box control populated programmatically, the search ignores the uppercase and lowercase characters.
  • If the control is a List Box control based on a data file, the search performed on the "Key" items takes into account the search options defined in the data model editor ("General" tab of the item description).
Universal Windows 10 AppAndroidiPhone/iPad

Seeking and selecting an element in a List Box or Combo Box control

To seek and/or select an element in a List Box or Combo Box control based on a data file, you can use the following syntax:
LIST_OrderList.StoredItem = "CustomerID"
// Find and select the element whose CustomerID is "135"
LIST_OrderList = 135
// If the element sought is not found, LIST_OrderList will be set to -1
Android The sought element is selected.
Universal Windows 10 AppiPhone/iPad

Seeking an element in a List Box or Combo Box control based on a data file: search on the stored value or on the displayed value

Case 1: The List Box or Combo Box control is populated with the data from a data file ("Direct access" option):
The search is performed according to the value of gStoredValueEnable:
  • If gStoredValueEnable(Control, True) (by default): <List Box>.Seek performs the search on the "search item" declared in the "Content" tab of control description.
  • If gStoredValueEnable(Control, False): <List Box>.Seek performs the search on the "displayed item" declared in the "Content" tab of control description.
Case 2: The List Box or Combo Box control is populated with the data from a data file ("Loaded in memory" option):
<List Box>.Seek performs the search on the "displayed item" declared in the "Content" tab of control description.
Universal Windows 10 AppAndroidiPhone/iPad

Search and selection in a List Box control

If the options used to populate the List Box control are defined in the description window of the control ("Content" tab), the following syntax can be used to seek and select an element in a List Box control:
ListBoxName = SoughtElement
The options used to populate the List Box control are:
  • Browsed file,
  • Displayed item,
  • Search item.
Description of List Box control based on a data file
Component: wd290obj.dll
Minimum version required
  • Version 23
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/19/2023

Send a report | Local help