The text type of a table cell can be defined using the TableCellFormat.TextType TX Text Control .NET for Windows Forms
TXTextControl Namespace
TableCellFormat Class
TextType Property
Gets or sets the text type of the table cell which determines whether the cell's text is interpreted as a number or as text When the type is Standard, the cell's text is interpreted as text and it is displayed as it is.
property which can be either plain text (Standard) or a Number. When defined as text, the string is rendered as is. But when defined as a number, the formatting of the rendered string can be defined. In the following screen video, the table cell text is defined as a number (currency). When changing the cell's text, the associated format is applied automatically when leaving the table cell.

Formatting numbers in Text Control

The table cell format will be applied to any cell content. The following screen video shows a calculated formula that uses the applied string formatter:

Formatting numbers in Text Control

The same is valid for form fields and merge fields that are inserted in a table cell:

Formatting numbers in Text Control

Default Formatting

By default, the rendered text without decimal places is displayed as an integer. If a decimal number is rendered, it is getting rendered with all its decimal places.

The TableCellFormat.NumberFormat TX Text Control .NET for Windows Forms
TXTextControl Namespace
TableCellFormat Class
NumberFormat Property
Gets or sets a number format for the table cell.
property is used to set a number format string, that is a composition of placeholders ('#' or/and '0'), separators ('.' or/and ','), percentage signs ('%') and other single characters or text.

Using Placeholders

Digit placeholders represent positions inside the number to format. As placeholders, 2 kind of characters can be used: '#' and '0' - where the placeholder '0' fills those positions with zeros in case the corresponding position is not reserved by a digit of the calculation's result value.

The following examples show the value, the placeholder and the result:

Number Placeholder Result
7 # 7
123 # 123
7 0 007
123 000 123

Separators

Separators are used to render a number as a decimal number or/and to render with a thousands separator. Depending on the system language, the separator signs are rendered with the system's default digit or thousands separator signs (an English system uses a period to indicate the decimal place and a comma as thousand separator).

Decimal Numbers

To define a format where all numbers are displayed with decimal places, the placeholder must be combined with a digit point ('.'). The number of placeholders after the separator defines the maximum number of decimal places to be rendered. Results are rounded to the next integer value.

Number Format Result
12.7 #.## 12.7
2 #.00 2.00
12.7 #.00 12.70
0.123 #.00 0.12

Thousands Separator

The thousands separator (',') is used in combination with appended placeholders. The result is rendered with a comma at each third digit. If no placeholder is defined after the comma, the number is trimmed by three pre-decimal point positions at each comma location.

Number Format Result
9876543210.1234 ,###.## 9,876,543,210.12
9876543210 ,### 9,876,543,210
12200000 #,, 12
12200000 #.0,, 12.2

Percentages

In order to render percentages, the percentage symbol ('%') can be used in combination with one or more placeholders. The resulting value is multiplied by 100 and shown together with the percentage symbol.

Number Format Result
0.52 #% 52%
1 #% 1%
0.00321 0.##% 0.32%
0.52 %# %52

Additional Text

The resulting number can be combined with a single character or a complete text. The following list shows predefined characters that can be combined with a number format string:

Symbol Number Value Result
$ (Dollar sign) 500 #$ 500$
- (Minus sign) 1 -#.00 -1.00
+ (Plus sign) 12.345 +.## +12.35
/ (Slash mark) 4 \1/# 1/4
( (Left parenthesis) 7 -(#+\3) -(7+3)
) (Right parenthesis) 3 -(\7+#) -(7+3)
: (Colon) 50 #:"50" 50:50
! (Exclamation point) 6 #! 6!
^ (Circumflex accent (caret)) 2.5 #.00^\2 2.50^2
& (Ampersand) 0 #&\1 0&1
~ (Tilde) 7.654 ~#.0 ~7.7
{ (Left curly bracket) 67 {-#} {-67}
} (Right curly bracket) 17 {+#} {+17}
< (Less-than sign) 5 #<"10" 5<10
> (Greater-than sign) 7.4 #.00>\6 7.40>6
= (Equal sign) 5.6 #>=\6 6>=6
(Space character) 12 #.00 $ 12.00 $

Currency Symbols and Others

All other symbols such as currency symbols can be rendered by adding a backslash in front of the character to be rendered:

Number Format Result
12.99 #.00\? 12.99?
42 \"#\" "42"
18 #:\X 18:X
29.99 "USD" #.00 USD 29.99
76 # "units" 76 units