# TextCharCollection.Add Method

> Adds a character to the document.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 23.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WinForms.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > TextCharCollection.Add Method
- **1516 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcharcollection/add-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcharcollection/add-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcharcollection/add-method/llms-full.txt

---

### Description

Adds a character to the document.

### Syntax

#### Add(char)

Inserts a character at the current text input position.

```csharp
public bool Add(char character);
```

```vbnet
Public Function Add(character As Char) As Boolean
```

| Parameter | Description |
|---|---|
| character | Specifies the character to insert. |

#### Add(char, string)

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

```csharp
public bool Add(char character, string fontName);
```

```vbnet
Public Function Add(character As Char, fontName As String) As Boolean
```

| Parameter | Description |
|---|---|
| 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.

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

```vbnet
Public Function Add(character As Char, fontName As String, textPosition As Integer) As Boolean
```

| Parameter | Description |
|---|---|
| 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.

```csharp
public bool Add(ControlChars controlChar);
```

```vbnet
Public Function Add(controlChar As ControlChars) As Boolean
```

| Parameter | Description |
|---|---|
| controlChar | Specifies a control character to insert. It can be one of the [ControlChars](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/controlchars/enumeration/llms-full.txt) values. |

#### Add(ControlChars, int)

Inserts a control character at the specified text input position.

```csharp
public bool Add(ControlChars controlChar, int textPosition);
```

```vbnet
Public Function Add(controlChar As ControlChars, textPosition As Integer) As Boolean
```

| Parameter | Description |
|---|---|
| controlChar | Specifies a control character to insert. It can be one of the [ControlChars](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/controlchars/enumeration/llms-full.txt) 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`.

```csharp
TextCharCollection textCharCollection = textControl.TextChars;

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

```vbnet
Dim textCharCollection As TextCharCollection = textControl.TextChars

If Not textCharCollection.Add("A"c, "Arial") Then
    Throw New InvalidOperationException("The item could not be inserted.")
End If
```

---

## Nearby

- **Previous:** [TextCharCollection Class](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcharcollection/llms-full.txt)
- **Next:** [TextCharCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcharcollection/copyto-method/llms-full.txt)
