TX Text Control .NET for WPF

NumberFormat Property

Property|Introduced in 26.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.WPF.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Gets or sets a number format which can be used to automatically format numbers in table cells. When a formula is defined the automatically calculated text can also be formatted with a number format. When a number format is not defined, the property's value is an empty string. The number format string has a format as described in Office Open XML File Formats - ISO/IEC 29500 - 1, Chapter: 18.8.31 Number Formats. See Formatting Text by using Number Formats for more information. If text is selected, the property specifies the number format of the whole selected text.

Syntax

public string NumberFormat { get; set; }

Examples

The following example changes the formatting applied to text entered at the end of a document by using InputFormat.NumberFormat.

textControl.Text = "Project summary";
textControl.InputPosition = new InputPosition(textControl.Text.Length);
InputFormat inputFormat = textControl.InputFormat;

inputFormat.NumberFormat = "0.00";
if (!string.IsNullOrWhiteSpace(inputFormat.NumberFormat))
{
    Console.WriteLine($"Number Format: {inputFormat.NumberFormat}");
}

Remarks

The property returns null when the text selection contains multiple table cells with different number formats.