# ImageCollection.Add Method

> Inserts a new image in a Text Control document.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Method
- **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 > ImageCollection.Add Method
- **3605 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imagecollection/add-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imagecollection/add-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imagecollection/add-method/llms-full.txt

---

### Description

Inserts a new image in a Text Control document.

### Syntax

#### Add()

Inserts an image inline, which means that it is treated in the text like a single character. The image is inserted at the current text input position. A file open dialog box is shown to get the image's file name and filter.

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

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

#### Add(Image, int)

Inserts an image inline, which means that it is treated in the text like a single character. The image is inserted at the specified text input position. A file open dialog box is shown to get the image's file name and filter. To avoid opening the dialog box set the [Image.FileName](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filename-property/llms-full.txt) and the [Image.FilterIndex](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filterindex-property/llms-full.txt) properties of the specified [Image](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/llms-full.txt) object.

```csharp
public bool Add(Image image, int textPosition);
```

```vbnet
Public Function Add(image As Image, textPosition As Integer) As Boolean
```

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

#### Add(Image, HorizontalAlignment, int, ImageInsertionMode)

Inserts a new image which is anchored to the specified text position. It has the specified horizontal alignment and a textflow which is given through the insertionMode parameter. Anchored images are moved with the text. A file open dialog box is shown to get the image's file name and filter. To avoid opening the dialog box set the [Image.FileName](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filename-property/llms-full.txt) and the [Image.FilterIndex](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filterindex-property/llms-full.txt) properties of the specified [Image](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/llms-full.txt) object.

```csharp
public bool Add(Image image, HorizontalAlignment alignment, int textPosition, ImageInsertionMode insertionMode);
```

```vbnet
Public Function Add(image As Image, alignment As HorizontalAlignment, textPosition As Integer, insertionMode As ImageInsertionMode) As Boolean
```

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

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

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

| Value | Meaning |
| AboveTheText | The image is inserted at a certain geometrical location above the text. This means that the image overwrites the text. |
| BelowTheText | The image is inserted at a certain geometrical location below the text. This means that the text overwrites the image. |
| DisplaceCompleteLines | The text stops at the top and continues at the bottom of the image. |
| DisplaceText | The text flows around the image and empty areas at the left and right side are filled. |
| Other Vaues | All other values cannot be used with the ImageCollection.Add method. |

#### Add(Image, Point, int, ImageInsertionMode)

Inserts a new image which is anchored to the specified text position. It has the specified location relative to the paragraph it is anchored to and a textflow which is given through the insertionMode parameter. Anchored images are moved with the text. A file open dialog box is shown to get the image's file name and filter. To avoid opening the dialog box set the [Image.FileName](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filename-property/llms-full.txt) and the [Image.FilterIndex](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filterindex-property/llms-full.txt) properties of the specified [Image](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/llms-full.txt) object.

```csharp
public bool Add(Image image, Point location, int textPosition, ImageInsertionMode insertionMode);
```

```vbnet
Public Function Add(image As Image, location As Point, textPosition As Integer, insertionMode As ImageInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| image | Specifies the image to add. |
| location | Specifies the location, in twips, at which the image 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 image is to be inserted. If -1 is specified, the image is inserted at the current input position. |
| insertionMode | Specifies how the text flow is handled. It can be one of the following values of the [ImageInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imageinsertionmode/enumeration/llms-full.txt) enumeration:  \| Value \| Meaning \| \| AboveTheText \| The image is inserted at a certain geometrical location above the text. This means that the image overwrites the text. \| \| BelowTheText \| The image is inserted at a certain geometrical location below the text. This means that the text overwrites the image. \| \| DisplaceCompleteLines \| The text stops at the top and continues at the bottom of the image. \| \| DisplaceText \| The text flows around the image and empty areas at the left and right side are filled. \| \| Other Vaues \| All other values cannot be used with the ImageCollection.Add method. \| |
|---|

#### Add(Image, int, Point, ImageInsertionMode)

Inserts a new image which has a fixed geometrical position in the document. This position is specified through a page number and a location on this page. A file open dialog box is shown to get the image's file name and filter. To avoid opening the dialog box set the [Image.FileName](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filename-property/llms-full.txt) and the [Image.FilterIndex](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filterindex-property/llms-full.txt) properties of the specified [Image](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/llms-full.txt) object.

```csharp
public bool Add(Image image, int pageNumber, Point location, ImageInsertionMode insertionMode);
```

```vbnet
Public Function Add(image As Image, pageNumber As Integer, location As Point, insertionMode As ImageInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| image | Specifies the image to add. |
| pageNumber | Specifies the number of a page beginning with 1 where the image is located. |
| location | Specifies the location, in twips, at which the image 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 following values of the [ImageInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imageinsertionmode/enumeration/llms-full.txt) enumeration:  \| Value \| Meaning \| \| AboveTheText \| The image is inserted at a certain geometrical location above the text. This means that the image overwrites the text. \| \| BelowTheText \| The image is inserted at a certain geometrical location below the text. This means that the text overwrites the image. \| \| DisplaceCompleteLines \| The text stops at the top and continues at the bottom of the image. \| \| DisplaceText \| The text flows around the image and empty areas at the left and right side are filled. \| \| Other Vaues \| All other values cannot be used with the ImageCollection.Add method. \| |
|---|

#### Add(Image, Point, ImageInsertionMode)

Inserts a new image which has a fixed geometrical position in the document. This position is specified through a location relative to the top left corner of the complete document. All gaps between the pages must be included. A file open dialog box is shown to get the image's file name and filter. To avoid opening the dialog box set the [Image.FileName](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filename-property/llms-full.txt) and the [Image.FilterIndex](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filterindex-property/llms-full.txt) properties of the specified [Image](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/llms-full.txt) object.

```csharp
public bool Add(Image image, Point location, ImageInsertionMode insertionMode);
```

```vbnet
Public Function Add(image As Image, location As Point, insertionMode As ImageInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| image | Specifies the image to add. |
| location | Specifies the location, in twips, at which the image 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 following values of the [ImageInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imageinsertionmode/enumeration/llms-full.txt) enumeration:  \| Value \| Meaning \| \| AboveTheText \| The image is inserted at a certain geometrical location above the text. This means that the image overwrites the text. \| \| BelowTheText \| The image is inserted at a certain geometrical location below the text. This means that the text overwrites the image. \| \| DisplaceCompleteLines \| The text stops at the top and continues at the bottom of the image. \| \| DisplaceText \| The text flows around the image and empty areas at the left and right side are filled. \| \| Other Vaues \| All other values cannot be used with the ImageCollection.Add method. \| |
|---|

### Return Value

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

### Examples

The following example inserts a named, accessible company logo at the current input position.

```csharp
TXTextControl.Image logo = new() { FileName = @"Images\company-logo.png", Name = "CompanyLogo", DescriptiveText = "Company logo" };
if (!textControl.Images.Add(logo, -1))
{
    throw new InvalidOperationException("The logo could not be inserted.");
}
```

```vbnet
Dim logo As New TXTextControl.Image() With { .FileName = "Images\company-logo.png", .Name = "CompanyLogo", .DescriptiveText = "Company logo" }
If Not textControl.Images.Add(logo, -1) Then
    Throw New InvalidOperationException("The logo could not be inserted.")
End If
```

---

## Nearby

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