# TextFrameCollection.Add Method

> Inserts a new text frame in a Text Control document.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 12.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.Core.SDK` (assembly `TXTextControl.Core.dll`, from the private NuGet feed or Text Control Offline Packages)
- **Package:** `TXTextControl.TextControl.ASP.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 Server > Reference > TXTextControl > TextFrameCollection.Add Method
- **2728 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textframecollection/add-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textframecollection/add-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textframecollection/add-method/llms-full.txt

---

### Description

Inserts a new text frame in a Text Control document.

### Syntax

#### Add(TextFrame, int)

Inserts a text frame inline, which means that it is treated in the text like a single character. The frame is inserted at the specified text position.

```csharp
public bool Add(TextFrame textFrame, int textPosition);
```

```vbnet
Public Function Add(textFrame As TextFrame, textPosition As Integer) As Boolean
```

| Parameter | Description |
|---|---|
| textFrame | Specifies the text frame to add. |
| textPosition | Specifies the text position at which the text frame is to be inserted. If -1 is specified, the text frame is inserted at the current input position. |

#### Add(TextFrame, HorizontalAlignment, int, TextFrameInsertionMode)

Inserts a text frame which is anchored to the paragraph containing the specified text position. The frame has the specified horizontal alignment. TextFrameInsertionMode.FixedOnPage and TextFrameInsertionMode.AsCharacter cannot be specified with this overload.

```csharp
public bool Add(TextFrame textFrame, HorizontalAlignment alignment, int textPosition, TextFrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(textFrame As TextFrame, alignment As HorizontalAlignment, textPosition As Integer, insertionMode As TextFrameInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| textFrame | Specifies the text frame to add. |
| alignment | Specifies the text frame's horizontal alignment. It can be one of the [HorizontalAlignment](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/horizontalalignment/enumeration/llms-full.txt) values:  \| Value \| Meaning \| \| Left \| The text frame is left aligned relative to the paragraph to which it is anchored. \| \| Right \| The text frame is right aligned relative to the paragraph to which it is anchored. \| \| Centered \| The text frame is centered relative to the paragraph to which it is anchored. \| \| Justify \| This value is not possible for the alignment of text frames. \| |
|---|

| textPosition | Specifies the text position at which the text frame is to be inserted. If -1 is specified, the text frame is inserted at the current input position. |
|---|---|

| insertionMode | Specifies how the text flow is handled. It can be one of the values of the [TextFrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textframeinsertionmode/enumeration/llms-full.txt) enumeration. |

#### Add(TextFrame, Point, int, TextFrameInsertionMode)

Inserts a text frame which is anchored to the paragraph containing the specified text position. The frame has the specified position relative to the paragraph containing its anchor position. TextFrameInsertionMode.FixedOnPage and TextFrameInsertionMode.AsCharacter cannot be specified with this overload.

```csharp
public bool Add(TextFrame textFrame, Point location, int textPosition, TextFrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(textFrame As TextFrame, location As Point, textPosition As Integer, insertionMode As TextFrameInsertionMode) As Boolean
```

| Parameter | Description |
| textFrame | Specifies the text frame to add. |
| location | Specifies the location, in twips, at which the text frame is to be inserted. This is a location relative to the top left corner either of a page or of a paragraph. |
| textPosition | Specifies the text position at which the text frame is to be inserted. If -1 is specified, the text frame is inserted at the current input position. |
| insertionMode | Specifies how the text flow is handled. It can be one of the values of the [TextFrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textframeinsertionmode/enumeration/llms-full.txt) enumeration. |

#### Add(TextFrame, int, Point, TextFrameInsertionMode)

Inserts a text frame that has a fixed geometrical position in the document. This position is specified through a page number and a location on this page. TextFrameInsertionMode.MoveWithText and TextFrameInsertionMode.AsCharacter cannot be specified with this overload.

```csharp
public bool Add(TextFrame textFrame, int pageNumber, Point location, TextFrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(textFrame As TextFrame, pageNumber As Integer, location As Point, insertionMode As TextFrameInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| textFrame | Specifies the text frame to add. |
| pageNumber | Specifies the number of a page beginning with 1 where the text frame is located. |
| location | Specifies the location, in twips, at which the text frame is to be inserted. This is a location relative to the top left corner either of a page or of a paragraph. |
| insertionMode | Specifies how the text flow is handled. It can be one of the values of the [TextFrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textframeinsertionmode/enumeration/llms-full.txt) enumeration. |

#### Add(TextFrame, Point, TextFrameInsertionMode)

Inserts a text frame that has a fixed geometrical position in the document. This location is specified through a document position relative to the top left corner of the complete document. TextFrameInsertionMode.MoveWithText and TextFrameInsertionMode.AsCharacter cannot be specified with this overload.

```csharp
public bool Add(TextFrame textFrame, Point location, TextFrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(textFrame As TextFrame, location As Point, insertionMode As TextFrameInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| textFrame | Specifies the text frame to add. |
| location | Specifies the location, in twips, at which the text frame is to be inserted. This is a location relative to the top left corner either of a page or of a paragraph. |
| insertionMode | Specifies how the text flow is handled. It can be one of the values of the [TextFrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textframeinsertionmode/enumeration/llms-full.txt) enumeration. |

#### Add(TextFrame, TextFrameInsertionMode)

Inserts a text frame with the built-in mouse interface. The text frame's size is determined through the end-user. A cross cursor indicates where the text frame can be inserted. Changing the document or pressing the ESC key aborts the insertion process.

```csharp
public bool Add(TextFrame textFrame, TextFrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(textFrame As TextFrame, insertionMode As TextFrameInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| textFrame | Specifies the text frame to add. |
| insertionMode | Specifies how the text flow is handled. It can be one of the values of the [TextFrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textframeinsertionmode/enumeration/llms-full.txt) enumeration. |

### Return Value

The return value is true, if the text frame could be added. Otherwise, it is false.

### Examples

The following example works with text frames in the current document by using `TextFrameCollection.Add`.

```csharp
TextFrameCollection textFrameCollection = textControl.TextFrames;

if (!textFrameCollection.Add(new TextFrame(new System.Drawing.Size(600, 400)), -1))
{
    throw new InvalidOperationException("The item could not be inserted.");
}
```

```vbnet
Dim textFrameCollection As TextFrameCollection = textControl.TextFrames

If Not textFrameCollection.Add(New TextFrame(New System.Drawing.Size(600, 400)), -1) Then
    Throw New InvalidOperationException("The item could not be inserted.")
End If
```

---

## Nearby

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