ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Combo Box control
  • Overview
  • Tip: How to refresh the content of an auto-filled Combo Box control that uses a query as a data source?
  • Initialization code of a Combo Box control programmatically linked to a data file
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
Linking a Combo Box control to a data file
Overview
A List Box or Combo Box control can be used to display the content of a data file, to allow a user to select a record, for example.
A Combo Box control can be initialized with the content of a data file:
  • automatically: No specific code is required to initialize the control. The options to loop through the data file linked to the control can be defined in the "Content" tab of the control description.
  • programmatically: The code used to loop through the data file linked to the Combo Box control must be entered in the initialization code of the control. This method is not recommended.
Remark: When creating a Combo Box control, the wizard will ask for all the details required to link the control to a data file.
Tip: How to refresh the content of an auto-filled Combo Box control that uses a query as a data source?
If you are using a Combo Box control based on a query with automatic initialization, to refresh the control content, type the following code (in the initialization code of the control for example). This code performs the following operations:
  1. Execute the base query of the Combo Box control again (specifying the query parameters, if necessary) with HExecuteQuery.
  2. Display the content of the Combo Box control again with ListDisplay.
// -- Initialization of a Combo Box control
HExecuteQuery(MyQRY, hQueryDefault, Param1, Param2)
ListDisplay(COMBO_ComboName, taStart)
Initialization code of a Combo Box control programmatically linked to a data file
If you use a Combo Box control based on a data file with programmed initialization, you must write the code to loop through the data file in the control initialization code.
For example: Initialization of a Combo Box control with the customers of the CUSTOMER data file.
// -- Initialization of a Combo Box control
HReadFirst(CUSTOMER, CustName)
WHILE NOT HOut()
ListAdd(COMBO_Combo1, Customer.CustName)
HReadNext(CUSTOMER, CustName)
END
Minimum version required
  • Version 9
This page is also available for…
Comments
//COMBO PROGRAM + QUERY DESIGN + FILTER DYNAMIC
//a) Insira um combo na tela

//b) click com o direito do mouse e escolha a opção CONTENT

//c) Escolha tipo "Table" vai liberar o Botão [Edit The Columns...]

//d) Informe as colunas que deseja ter no combo

//e) Ainda em CONTENT, Source Informe a coluna que será visivel do controle

//f) Em Details, Marque a opção Editable Combo box [x]

//g) Coloque um botao e esse código abaixo:

QRY_Select_T015_Empresas_Filtro.ParamEmpresaID = gsProfissionalXEmpresas

HExecuteQuery(QRY_Select_T015_Empresas_Filtro, hQueryDefault,gsProfissionalXEmpresas)

ListDeleteAll(COMBO_QRY_T015_EMPRESAS_FILTRO)

FOR EACH QRY_Select_T015_Empresas_Filtro
ListAdd(COMBO_QRY_T015_EMPRESAS_FILTRO,QRY_Select_T015_Empresas_Filtro.T015_COD_EMPRESA +TAB+ QRY_Select_T015_Empresas_Filtro.T015_DESCRICAO)
END
BOLLER
12 Apr. 2019

Last update: 01/12/2023

Send a report | Local help