PC SOFT

WINDEV的在线文档

  • 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 the numeric values
  • Aligning the numeric values
  • Aligning numbers on the decimal separator
  • Retrieving the content of the List Box control
  • Alignment in the editable Combo Box controls
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系:info@cn.windev.com
产品
WinDevWebDev-服务器代码WebDev-浏览器代码WinDev Mobile报表和查询
平台
WindowsLinuxWindows MobileWindows PhoneWindows Store appsAndroidAndroid Widget iPhone/iPad
语言
JavaPHPAjax用户代码(MCU)外部语言
数据库
HFSQLHFSQL Client/Server存储过程HF 5.5OLE DBODBC本地访问

Aligning elements in a List Box or Combo Box control

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 the left or to the right
    • Alignment with spaces (method available for the non-proportional fonts only).
  • For the numeric values: Aligning 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补全"MALTESE"8)+TAB+"Corto"
列表添加LIST_LIST2"SCROOGE"+TAB+"John"
列表添加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 列表添加 defines the positions of the 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 列表添加, don't forget to reserve "sufficient space" for the other elements of the control. For example, if you know that the largest element of the list will have 20 letters, the size can be defined by 补全.

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 width of the control.

// The first element is filled to reserve the size
列表添加LIST_LIST3定界符+补全"MALTESE"8)+...
TAB+定界符+"Corto"
列表添加LIST_LIST3定界符+"SCROOGE"+TAB+定界符+"John"
列表添加LIST_LIST3定界符+"ANA"+TAB+定界符+"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:

LineLIST_List41

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 the 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补全"MALTESE"8)+"Corto"
列表添加LIST_LIST1补全"SCROOGE"8)+"John"
列表添加LIST_LIST1补全"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 the numeric values

Aligning the 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 the 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 列表添加 defines the width of elements. So, don't forget to reserve enough space for the element width when adding the first row to the control.

列表添加LIST_LIST4补全"FRANCE"7)+TAB+定界符+...
"  30"+TAB+",00"
列表添加LIST_LIST4"CANADA"+TAB+定界符+"10"+TAB+",00"
列表添加LIST_LIST4"SWITZERLAND"+TAB+定界符+"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 in the list box:

LineLIST_List41

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_LIST5text2+TAB+定界符+"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字符串型
Str=我自己
// "FRANCE"+TAB+eot+30+tab+,00
Col1字符串型提取字符串Str1// France
Col2字符串型提取字符串Str2// eot+30
Col3字符串型提取字符串Str3// ,00
// Extract the EOT character
Col2提取字符串Col22定界符

我自己=无空格Col1)+" "+无空格Col2)+无空格Col3