ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Combo Box control
  • Overview
  • Initializing and populating a Combo Box control
  • Initializing an element
  • Initializing input in an editable Combo Box control
  • Populating a Combo Box control
  • Selecting an element in a Combo Box control
  • Selecting an element in a Combo Box control
  • Selecting the last element of a Combo Box control
  • Retrieving the element selected in the Combo Box control
  • Retrieving the index of the selected element
  • Getting the value of the selected element
  • Finding an element in a Combo Box control with a table
  • Properties specific to Combo Box 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, WINDEV Mobile and WEBDEV allow you to programmatically manipulate Combo Box controls. To do so, use the variable of the Combo Box control in the code. This variable is of type numeric.
The variable of the Combo Box control:
  • corresponds to the name of the Combo Box control.
  • is initialized with the index of the element selected in the control.
To handle an element of the Combo Box control, use the following notation:
<Combo Box control>[<Element index>]
Remark: There are multiple WLanguage functions specific to Combo Box controls. For more details, see: List Box and Combo Box management functions and functions specific to Combo Box controls.
Initializing and populating a Combo Box control

Initializing an element

To initialize an element in a standard or editable Combo Box control, use <List Box>.Add.
To modify an element in a standard or editable Combo Box control, use a direct assignment:
<Combo Box control>[index] = <Value>
Android In Android, negative or null values cannot be assigned to a Combo Box control. If the Combo Box control is not empty, an element has to be selected. An error will occur if a negative or null value is assigned to a Combo Box control.
WINDEVJava

Initializing input in an editable Combo Box control

To initialize input in an editable Combo Box, use:
  • direct assignment:
    <Combo Box control> = <Value>
  • the <List Box>.Add function.
    // Add elements to a Combo Box control
    COMBO_COMBO1.Add("MOORE")
    COMBO_COMBO1.Add(Cust_Name)

Populating a Combo Box control

To initialize a Combo Box control, simply use an iteration loop to initialize all the elements in the control.
Index is int
FOR Index = <Start position> TO <End position>
<Combo Box control>.Add(<Value>)
END
Example:
i is int
FOR i = 1 TO 52
COMBO_COMBO.Add(NAME[i]) 
END
Selecting an element in a Combo Box control

Selecting an element in a Combo Box control

To select the element at row <Index>, use:
  • direct assignment:
    <Combo Box control> = Index
  • the <List Box>.SelectPlus function:
    <Combo Box control>.SelectPlus(<Index>)
WINDEVJava Remark: Only the second syntax can be used in an editable Combo Box control.
Remark: If the Combo Box control is initialized with gStoredValue, the value of gStoredValue must be used to select an element.
For example, if the Combo Box control is initialized with the code:
ListAdd(COMBO_Person, "My text" + gStoredValue("StoredValue"))
the following code will be used to select an element:
COMBO_Person = StoredValue

Selecting the last element of a Combo Box control

To set the position on the last element of the Combo Box control, use:
  • the Count property:
    <Combo Box control> = <Combo Box control>.Count
  • <List Box>.SelectPlus associated with the Count property:
    <Combo Box control>.SelectPlus(<Combo Box control>.Count)
  • the <List Box>.Count function:
    <Combo Box control> = <Combo Box control>.Count()
WINDEVJava Remark: Only the last syntax can be used in an editable Combo Box control.
Retrieving the element selected in the Combo 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 = <Combo Box control>

Getting the value of the selected element

To retrieve the value of selected element, use one of the following syntaxes:
  • Syntax 1: Non-editable Combo Box control
    index is int = <Combo Box control>
    <Variable> = <Combo Box control>[Index]
  • Syntax 2: Non-editable Combo Box control
    <Variable> = <Combo Box control>[<Combo Box control>]
  • Syntax 3: Editable or non-editable Combo Box controls: DisplayedValue property
    WEBDEV - Server code Server code only
    <Variable> = <Combo Box control>.DisplayedValue
  • WINDEVJava Specific syntax: Editable Combo Box control:
    <Variable> = <Combo Box control>
Finding an element in a Combo Box control with a table
WINDEVJava To find an element in a Combo Box control with a table, use TableSearch.
Reminder: To perform a search in a "standard" Combo Box control, use <List Box>.Seek.
Properties specific to Combo Box controls
The following properties are used to manage Combo Box controls:
All types of Combo Box controls
HorizontalAlignmentGets and sets the horizontal alignment of the elements in the Combo Box control.
EllipsisGets and sets the ellipsis mode.
LineHeightGets and sets the height of the rows in a Combo Box control.
MemoryIndicates if the specified Combo Box control is populated programmatically or is based on a data file.
CountGets the number of rows in a Combo Box control.
FillTypeIndicates how a Combo Box control is populated (programmatically, from a data file or from a variable).
EmptyIndicates if a Combo Box control is empty.
Editable Combo Box control only
WithInputGets and sets the input mode of the Combo Box control (editable or not editable).
CursorGets and sets the position of the mouse cursor in a control.
CursorEndGets and sets the end position of a selection made with the cursor.
MemoryFormatGets and sets the format of the returned value.
DisplayMaskGets and sets the display mask.
InputMaskGets and sets the input mask.
SizeGets and sets the maximum number of characters in the input field of the Combo Box control.
SelectedTextGets and changes the text selected in the input field of the Combo Box control.
InputTypeGets and sets the type of data entered in the input field of the Combo Box control.
Non-editable Combo Box control only
SearchAAFAllows you to:
  • determine if the search option is enabled on a non-editable Combo Box control,
  • enable or disable the search option via the AAF in a non-editable Combo Box control.
Combo Box populated programmatically only
InitialContentGets the initial content of a Combo Box control populated programmatically.
SortedIndicates if a Combo Box control populated programmatically is sorted, or sorts the control.
Combo Box control based on a data file only
BrowsedFileGets and sets the data file or query used to display the records in Combo Box controls.
AutoBrowseIndicates if a Combo Box control is looped through automatically or programmatically.
DisplayedItemGets and sets the item displayed in a Combo Box control.
StoredItemGets and sets the stored item of a Combo Box control.
BrowsedItemGets and sets the item used to automatically loop through Combo Box controls.

For a complete list of WLanguage properties that can be used with Combo Box controls, see Combo Box control properties.
Minimum version required
  • Version 23
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 11/20/2023

Send a report | Local help