PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Overview
  • The different methods for aligning text
  • Aligning elements with the TAB character
  • Aligning elements to the right or left
  • Retrieving elements from a List Box control
  • Alignment by spaces (available for monospaced fonts only)
  • Aligning numeric values
  • Aligning numeric values
  • Aligning numbers on the decimal separator
  • Retrieving the content of the 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/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
There are different methods to align the elements in a List Box or Combo Box control:
  • For text:
    • Alignment of elements by TAB. Elements can be aligned to the left or right.
    • Alignment by spaces (available for monospaced fonts only).
  • For the numeric values: Alignment of numbers on the decimal separator.
  • For editable Combo Box controls.
The different methods for aligning text

Aligning 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 then multiplied by the number of characters 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 <List Box>.Add is called for the first time, there must be "sufficient space" for the other control elements. For example, if you know that the largest element displayed in the control will contain 20 letters, you can fix the size using Complete.

Aligning elements to the right or left

By default, the text of the elements is aligned to the left. You can also use the TAB character to align the text of the elements to the left.
To align an element to the right, simply use the EOT character (before the text to be displayed 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
Therefore, any EOT and TAB characters should be extracted.

Alignment by spaces (available for monospaced fonts only)

Using a variable-width font makes alignment difficult in List Box controls containing multiple elements on a single row.
For example, if the List Box control uses the "Arial" font and has two elements, the code below will display the List Box control as follows (non-aligned elements):
LIST_LIST1.Add(Complete("MALTESE", 8) + "Corto")
LIST_LIST1.Add(Complete("SCROOGE", 8) + "John")
LIST_LIST1.Add(Complete("ANA", 8) + "Yoko")
Although the first element is set to occupy the space of 8 characters, the second element will not be aligned.
Each character of a proportional font has its own width. Proportional fonts do not allow you to align elements based on spaces.
However, you can use this method with non-proportional fonts such as "Courier".
Aligning numeric values

Aligning numeric values

Both numeric values and text can be aligned using same method (see previous paragraph). However, numeric values can also be aligned on 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 mentioned, the first call to <List Box>.Add determines the width of the elements. Therefore, you should make sure the first row you add to the control sets enough width for the other elements.
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 the 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 of the List Box control:
Line = LIST_List4[1]
The Line variable contains the following text: "France " + TAB + EOT + " 30" + TAB + ",00"
Therefore, any EOT and TAB characters should be extracted.
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 monospaced font (such as "Courier") and align the elements with spaces without using TAB or EOT characters (recommended solution).
  • extract the EOT and TAB characters form the selected element. To do so, write the corresponding process in the "Whenever modifying" event of the control.
In this case, the user won't be able to select an element in the Combo Box control using the keyboard, but only with the mouse.
For a Combo Box control whose elements have been added according to the following format:
ListAdd(LIST_LIST5, 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 version required
  • Version 23
This page is also available for…
Comments
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
15 Apr. 2019
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
15 Apr. 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
15 Apr. 2019