The Digits Element Alignment

Download the sample application: digits_01.zip

When the displayed value of the Digits element increases, the added numbers of digits by default appear from left to right:

However, it is also possible to draw numbers of digits from right to left when the lowest one is always on the right:

In order to do that you can use the next expression in the Text property:

 Designer   Expressions Window  

  

if (Slider1.Value / 1000 >= 1, 
format(round(Slider1.Value),"0"),
 if (Slider1.Value / 100 >= 1, 
 format(round(Slider1.Value)," 0"),
  if (Slider1.Value / 10 >= 1, 
  format(round(Slider1.Value),"  0"), 
  format(round(Slider1.Value),"   0")
    )
   )
  )

The display of the value format is set in accordance with conditions: when the value not exceeds 10, format function draws 3 empty numbers of digits; if the value is greater or equal to 10 but lower than 100, format function draws 2 empty numbers of digits, etc. (The quantity of according conditions depend on the maximum possible value). So, the lowest digit order number is always displayed on the latest position.

You can download the sample described above.

It is also sometimes required to display value always in the middle, regardless of growing or decreasing of digit order numbers:

In order to do that you can use the next expression in the Size property of the Digits element:

 Designer   Expressions Window  

  

if (Slider1.Value / 1000 >= 1, 
  [58px, 28px], 
  if (Slider1.Value / 100 >= 1, 
    [44px, 28px], 
    if (Slider1.Value / 10 >= 1, 
      [30px, 28px], 
      [16px, 28px]
      )
    )
  )

You can set conditions to the Size property and change the element size in accordance with the number of digits, keeping the element in the center.

Add Feedback