PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • The different methods for aligning text
  • Aligning the elements with the TAB character
  • Aligning the elements to right or to left
  • Retrieving elements from a List Box control
  • Alignment with spaces (method available for the non-proportional fonts only)
  • Aligning numeric values
  • Aligning numeric values
  • Aligning numbers on the decimal separator
  • Retrieving the content of List Box control
  • Alignment in the editable Combo Box controls
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
Several methods can be used to align the elements found in a Combo Box (or List Box) control
  • For the text:
    • Alignment of elements by TAB. The elements can be aligned to left or to right.
    • Alignment with spaces (method available for the non-proportional fonts only).
  • For the numeric values: Alignment of numbers on the decimal separator.
  • For the editable combo boxes.
The different methods for aligning text

Aligning the elements with the TAB character

To align the elements found in a List Box or Combo Box control, the easiest solution is to use the TAB character.
// The first element is filled to reserve the size
LIST_LIST2.Add(Complete("MALTESE", 8) + TAB + "Corto")
LIST_LIST2.Add("SCROOGE" + TAB + "John")
LIST_LIST2.Add("ANA" + TAB + "Yoko")
With the TAB character, the width of each element is calculated by taking the character "E" as reference. This reference width is multiplied by the number of characters found in each element.
Important: The first call to <List Box>.Add defines the positions of tabs for the entire List Box control and for the other List Box controls in the window. Therefore, as soon as the first call to <List Box>.Add, don't forget to reserve "sufficient space" for the other control elements. For example, if you know that the largest element in the list will contain 20 letters, the size can be defined by Complete.

Aligning the elements to right or to left

By default, the text of the elements is aligned to the left. Indeed, the TAB character allows you to align the text of elements to the left.
To align an element to the right, all you have to do is use the EOT character (in front of the text to display in the List Box control).
The elements that use the EOT character will be aligned to the right regardless of the control width.
// The first element is filled to reserve the size
LIST_LIST3.Add(EOT + Complete("MALTESE", 8) + ...
TAB + EOT + "Corto")
LIST_LIST3.Add(EOT + "SCROOGE" + TAB + EOT + "John")
LIST_LIST3.Add(EOT + "ANA" + TAB + EOT + "Yoko")

Retrieving elements from a List Box control

When retrieving an element from a List Box control, the entire line is returned, including the possible EOT and TAB characters.
For example, for the previous List Box control, the function below retrieves the first element:
Line = LIST_List4[1]
The Line variable contains the following text: <EOT>MALTESE <TAB><EOT>Corto
So, don't forget to extract the EOT and TAB characters if necessary.

Alignment with spaces (method available for the non-proportional fonts only)

In the List Box controls containing several elements on the same row, using a variable-size font makes it difficult to align elements.
For example, if the List Box control is using the "Arial" font and if it includes two elements, the following process will display the list in the following format (the elements are not aligned):
LIST_LIST1.Add(Complete("MALTESE", 8) + "Corto")
LIST_LIST1.Add(Complete("SCROOGE", 8) + "John")
LIST_LIST1.Add(Complete("ANA", 8) + "Yoko")
Even though the first element is filled to 8 characters, the second element will not be aligned.
Indeed, with proportional fonts, each character has its own width. The proportional fonts do not allow you to align the elements with spaces.
However, this method can be used with the non-proportional fonts such as "Courier".
Aligning numeric values

Aligning numeric values

The method for aligning numeric values is the same as the method for aligning text values (see the previous paragraph). However, the numeric values can also be aligned according to the decimal separator.

Aligning numbers on the decimal separator

To align the numbers on the decimal point, you must combine the use of TAB and EOT characters:
  • the integer part is aligned to the right.
  • the decimal part (including the decimal point) is aligned to the left.
As already said before, the first call to <List Box>.Add defines the width of elements. So, don't forget to reserve enough space for the width of elements when adding the first row into the control.
LIST_LIST4.Add(Complete("FRANCE", 7) + TAB + EOT + ...
"  30" + TAB + ",00")
LIST_LIST4.Add("CANADA" + TAB + EOT + "10" + TAB + ",00")
LIST_LIST4.Add("SWITZERLAND" + TAB + EOT + "246")

Retrieving the content of List Box control

When retrieving an element from a List Box control, the entire line is returned, including the possible EOT and TAB characters.
For example for the previous control, the function below retrieves the first element in the list box:
Line = LIST_List4[1]
The Line variable contains the following text: "France " + TAB + EOT + " 30" + TAB + ",00"
So, don't forget to extract the EOT and TAB characters if necessary.
Alignment in the editable Combo Box controls
All the alignment methods presented above are available for the editable and non-editable Combo Box controls.
However, if the EOT and TAB characters are used to align the elements of an editable Combo Box control, the value displayed in the control when selecting the element contains the alignment characters.
In this case, you must:
  • use a fixed-size font ("Courier" type) and align the elements with spaces without using the TAB or EOT characters (this solution is recommended because it is the easiest one).
  • extract the EOT and TAB characters form the selected element. In this case, the proper process must be included in the "whenever modified" code of the control.
In this case, an element found in the Combo Box control can only be selected with the mouse, and not with the keyboard.
For a combo box whose elements have been added according to the following format:
LIST_LIST5.Add(text2 + TAB + EOT + "10" + TAB + ",00")
The process for extracting the TAB and EOT characters is as follows:
// -- Selecting a row in the Combo Box control
// Extract the TAB characters
Str is string
Str = MySelf
// "FRANCE"+TAB+eot+30+tab+,00
Col1 is string = ExtractString(Str, 1) // France
Col2  is string = ExtractString(Str, 2) // eot+30
Col3 is string = ExtractString(Str, 3) // ,00
// Extract the EOT character
Col2 = ExtractString(Col2, 2, EOT) //30

MySelf = NoSpace(Col1) + " " + NoSpace(Col2) + NoSpace(Col3)
Minimum required version
  • Version 23
This page is also available for…
Comments
Exemplo parte 1 e Parte 1
a) Insira um combo na tela
b) click com o direito do mouse e escolha a opção CONTENT
c) Click no Botão [Edit The Columns...] defina TABLE
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
BOLLER
Apr. 15 2019
Parte 1
PROCEDURE UI_FiltroCliente(gempresaid,gNome)

IF gNome <> "" THEN

sqlcodigo is string = [
select distinct
T001_CLIENTES.T001_ID_PESSOA as T001_ID_PESSOA,
T001_CLIENTES.T001_NOME as T001_NOME
from
T001_CLIENTES, T044_empresa_x_cliente
Where
T001_CLIENTES.T001_NOME like '%@Nome@%'
and T044_empresa_x_cliente.t044_id_empresa = @EmpresaID@
]

sqlcodigo = Replace(sqlcodigo,"@Nome@",gNome,IgnoreCase)
sqlcodigo = Replace(sqlcodigo,"@EmpresaID@",gempresaid,IgnoreCase)

dsQuery is Data Source

ListDeleteAll(COMBO_QRY_Clientes_Ativos)
BOLLER
Apr. 15 2019
Parte 2
   IF HExecuteSQLQuery(dsQuery,hQueryDefault,sqlcodigo) = True THEN

FOR EACH dsQuery

IF HFound(dsQuery) = True THEN

ListAdd(COMBO_QRY_Clientes_Ativos,dsQuery.T001_ID_PESSOA +TAB+ dsQuery.T001_NOME)

END

END

END

END

COMBO_QRY_Clientes_Ativos.Open()
BOLLER
Apr. 15 2019