TX Text Control .NET for WPF

Add Method

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

Description

Adds a character to the document.

Syntax

Add(char)

Inserts a character at the current text input position.

public bool Add(char character);
ParameterDescription
character

Specifies the character to insert.

Add(char, string)

Inserts a character at the current text input position using the specified font.

public bool Add(char character, string fontName);
ParameterDescription
character

Specifies the character to insert.

fontName

Specifies the name of the font which is used for the specified character.

Add(char, string, int)

Inserts a character at the specified position using the specified font.

public bool Add(char character, string fontName, int textPosition);
ParameterDescription
character

Specifies the character to insert.

fontName

Specifies the name of the font which is used for the specified character.

textPosition

Specifies a text input position. The first input position in a document is 0.

Add(ControlChars)

Inserts a control character at the current text input position.

public bool Add(ControlChars controlChar);
ParameterDescription
controlChar

Specifies a control character to insert. It can be one of the ControlChars values.

Add(ControlChars, int)

Inserts a control character at the specified text input position.

public bool Add(ControlChars controlChar, int textPosition);
ParameterDescription
controlChar

Specifies a control character to insert. It can be one of the ControlChars values.

textPosition

Specifies a text input position. The first input position in a document is 0.

Examples

The following example works with text chars in the current document by using TextCharCollection.Add.

TextCharCollection textCharCollection = textControl.TextChars;

if (!textCharCollection.Add('A', "Arial"))
{
    throw new InvalidOperationException("The item could not be inserted.");
}