ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / List Box functions
  • List control with more than 10,000 elements
  • Visibility/Invisibility of elements in a List Box or Combo Box control
  • Customizing the elements found in a List Box or Combo Box control
  • Sorted/Unsorted List Box control
  • Tabulations: Multi-selection List Box control
  • Miscellaneous
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
Inserts an element into a List Box, ListView or Combo Box control populated programmatically.
Remarks:
  • To add an element at the end of List Box (or Combo Box) control, use ListAdd.
  • ListInsert can be used on single-selection and multi-selection List Box controls
  • To manage the contents of a Combo Box control in a container column of a Table control, use the Content property.
Example
// Add "Clark" in 4th position to "LIST_CustomerList"
ListInsert(LIST_CustomerList, "Clark", 4)
WINDEVUser code (UMC)
// Add the "C:\MyImages\CoralReef.JPG" image in 5th position to "LSV_Diving"
// The caption of this image will be "Nice coral"
ListInsert(LSV_Diving, "Nice coral", "C:\MyImages\CoralReef.JPG", 4)
Syntax
<Result> = ListInsert(<List Box control> , <Element> [, <Image> [, <Element index>]])
<Result>: Boolean
  • True if the element was inserted,
  • False otherwise.
<List Box control>: Control name
Name of List Box or Combo Box control populated programmatically.
If this parameter corresponds to an empty string (""), the element is inserted in the List Box or Combo Box control to which the current process belongs.
<Element>: Character string
Element that must be inserted into the specified List Box (or Combo Box) control populated programmatically.
This parameter can contain:
  • Carriage Return characters (CR) to add several rows. In this case:
    • if <Element index> is not specified, the elements are added.
    • If <Element index> is specified, only the first element will be added.
  • tabs (TAB) to obtain a multi-element List Box control (see Notes).
WINDEVJava For a ListView control, this parameter corresponds to the image caption. This parameter can contain Carriage Return characters (CR) to add several elements. In this case:
  • if <Image> and <Element index> are not specified, the added elements will be associated with the default image (defined in the "Details" tab of the control description window).
  • if <Image> and <Element index> are specified, only the first element will be added. This element will be associated with the default image (defined in the "Details" tab of the description window of control).
  • if <Image> is specified and if <Element index> is not specified, only the first element will be added. This element will be associated with the specified image.
Java The Carriage Return characters (CR) and the tabulations (TAB) are not supported.
<Image>: Optional character string
Name and path of image that will be added into a ListView control. This parameter is taken into account for ListView controls displayed in ListView mode only. If this parameter is not specified, the default image (defined in the "Details" tab in the description window of control) will be used.
Universal Windows 10 App This parameter is not available.
<Element index>: Optional integer
Index of the element to be inserted.
If this parameter:
  • is not specified, the element is inserted:
    • before the current element in a single-selection List Box control. If there is no current element, the element is inserted at the last position in the List Box (or Combo Box) control populated programmatically.
    • at the last position in the List Box (or Combo Box) control populated programmatically, in a multi-selection List Box control.
  • is greater than the number of elements in the List Box (or Combo Box) control, the element is inserted at the last position in the List Box (or Combo Box) control populated programmatically. The number of elements in a List Box (or Combo Box) control is returned by ListCount.
  • is equal to 0, the element is added at the first position in the List Box (or Combo Box) control populated programmatically.
Remarks

List control with more than 10,000 elements

The maximum number of elements in a List Box control is only limited by the available memory (theoretical maximum: 2 billion rows). Nevertheless, populating a List Box control with a large number of elements (more than 10,000) affects performance.
To add a large number of elements, it is recommended to use a List Box control based on an HFSQL data file.
WINDEVJavaUser code (UMC)

Visibility/Invisibility of elements in a List Box or Combo Box control

To make an element invisible in a List Box or Combo Box control, use gStoredValue.
WINDEVUser code (UMC)

Customizing the elements found in a List Box or Combo Box control

To customize the elements in a List Box or Combo Box control (background color, image, drawing, etc.), use Graphic string management functions.
WINDEVUniversal Windows 10 AppJavaUser code (UMC)

Sorted/Unsorted List Box control

  • If the List Box control is sorted, the new element is inserted at the current position without sorting the list box.
  • If the List Box control is not sorted, the new element is added:
    • at <Element index> if <Element index> is specified.
    • before the current element in a single-selection List Box control if the <Element index> parameter is not specified. If there is no current element, the element is inserted at the last position in the List Box (or Combo Box) control populated programmatically.
    • at the last position of the List Box (or Combo Box) control populated programmatically in a multi-selection List Box control, if the <Element index> is not specified.
The type of the List Box control (sorted or not) is selected during the control description ("Details" tab).
Use ListAdd rather than ListInsert to add an element to a sorted List Box control.
WINDEVUser code (UMC)

Tabulations: Multi-selection List Box control

To manage the tabulations in a List Box control (alignment of columns), use the TAB constant. For example:
ListInsert(LIST_Customer, LastName + TAB + FirstName)
In this example, all the first names start at the same position and are aligned one under the other.
Remark: The first call to ListInsert defines the position of tabulations. These positions will be taken as reference for all values added thereafter. Similarly, if values have been typed entered in the editor, the positions of these values are taken as reference. During the first call to ListInsert, we advise you to define the width of columns with Complete. For example, to fix the width of columns found in "LIST_Customer" to 10 characters:
ListInsert(LIST_Customer, Complète(LastName, 10) + TAB + Complète(FirstName, 10))

Miscellaneous

  • To insert an element into a Table control, use TableInsert.
  • ListInsert can be used on a "Combo Box" column in a Table control .
Component: wd290obj.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Exemplo ListInsert
ListInsert(LIST_List,"Primeiro",1)
ListInsert(LIST_List,"Segundo",2)

ListInsert(LSV_Listview, "Imagen 1","D:\_GRAVACOES\Amarildo\Blog_Mandar_imagem\2016-10-04_1348.png", 1)
ListInsert(LSV_Listview, "Imagen 2","D:\_GRAVACOES\Amarildo\07112016_segunda\001\Video_Falta_1000.png", 2)

//Blog com Video E Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/11/aula-962-curso-windev-listbox-007.html
https://www.youtube.com/watch?v=M1jF2-ouHiw


De matos
04 Dec. 2016

Last update: 06/07/2022

Send a report | Local help