PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • 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
ListAdd(LIST_LIST2, Complete("MALTESE", 8) + TAB + "Corto")
ListAdd(LIST_LIST2, "SCROOGE" + TAB + "John")
ListAdd(LIST_LIST2, "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 ListAdd 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 ListAdd, 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
ListAdd(LIST_LIST3, EOT + Complète("MALTESE", 8) + ...
TAB + EOT + "Corto")
ListAdd(LIST_LIST3, EOT + "SCROOGE" + TAB + EOT + "John")
ListAdd(LIST_LIST3, 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):
ListAdd(LIST_LIST1, Complete("MALTESE", 8) + "Corto")
ListAdd(LIST_LIST1, Complete("SCROOGE", 8) + "John")
ListAdd(LIST_LIST1, 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 ListAdd 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.
ListAdd(LIST_LIST4, Complete("FRANCE", 7) + TAB + EOT + ...
"  30" + TAB + ",00")
ListAdd(LIST_LIST4, "CANADA" + TAB + EOT + "10" + TAB + ",00")
ListAdd(LIST_LIST4, "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:
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 required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment