# BarcodeCollection.Add Method

> Inserts a new barcode in a Text Control document.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 19.0
- **Namespace:** `TXTextControl.DataVisualization`
- **Package:** `TXTextControl.TextControl.WPF.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 WPF > Reference > TXTextControl.DataVisualization > BarcodeCollection.Add Method
- **3431 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-datavisualization/barcodecollection/add-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-datavisualization/barcodecollection/add-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-datavisualization/barcodecollection/add-method/llms-full.txt

---

### Description

Inserts a new barcode in a Text Control document.

### Syntax

#### Add(BarcodeFrame, int)

Inserts a barcode inline, which means that it is treated in the text like a single character.

```csharp
public bool Add(BarcodeFrame barcodeFrame, int textPosition);
```

```vbnet
Public Function Add(barcodeFrame As BarcodeFrame, textPosition As Integer) As Boolean
```

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

#### Add(BarcodeFrame, HorizontalAlignment, int, FrameInsertionMode)

Inserts a barcode, which is anchored to the specified text position. It has the specified horizontal alignment relative to the paragraph into which it is inserted and the textflow is given through the insertionMode parameter. An anchored barcode is moved with the text.

```csharp
public bool Add(BarcodeFrame barcodeFrame, HorizontalAlignment alignment, int textPosition, FrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(barcodeFrame As BarcodeFrame, alignment As HorizontalAlignment, textPosition As Integer, insertionMode As FrameInsertionMode) As Boolean
```

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

| textPosition | Specifies the text position at which the barcode is to be inserted. If -1 is specified, the barcode 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 [FrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/frameinsertionmode/enumeration/llms-full.txt) enumeration: |

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

#### Add(BarcodeFrame, Point, int, FrameInsertionMode)

Inserts a barcode, which is anchored to the specified text position. The specified location is relative to the paragraph into which it is inserted and the textflow is given through the insertionMode parameter. An anchored barcode is moved with the text.

```csharp
public bool Add(BarcodeFrame barcodeFrame, Point location, int textPosition, FrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(barcodeFrame As BarcodeFrame, location As Point, textPosition As Integer, insertionMode As FrameInsertionMode) As Boolean
```

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

#### Add(BarcodeFrame, int, Point, FrameInsertionMode)

Inserts a barcode, which has a fixed geometrical position in the document. This position is specified through a page number and a location on this page and the textflow is given through the insertionMode parameter.

```csharp
public bool Add(BarcodeFrame barcodeFrame, int pageNumber, Point location, FrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(barcodeFrame As BarcodeFrame, pageNumber As Integer, location As Point, insertionMode As FrameInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| barcodeFrame | Specifies the barcode and its frame to add. |
| pageNumber | Specifies the number of a page beginning with 1 where the barcode is located. |
| location | Specifies the location, in twips, at which the barcode is to be inserted. |
| insertionMode | Specifies how the text flow is handled. It can be one of the following values of the [FrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/frameinsertionmode/enumeration/llms-full.txt) enumeration:  \| Value \| Meaning \| \| AboveTheText \| The barcode is inserted at a certain geometrical location above the text. This means that the barcode overwrites the text. \| \| BelowTheText \| The barcode is inserted at a certain geometrical location below the text. This means that the text overwrites the barcode. \| \| DisplaceCompleteLines \| The text stops at the top and continues at the bottom of the barcode. \| \| DisplaceText \| The text flows around the barcode and empty areas at the left and right side are filled. \| \| Other Vaues \| All other values cannot be used with the BarcodeCollection.Add method. \| |
|---|

#### Add(BarcodeFrame, Point, FrameInsertionMode)

Inserts a barcode, which has a fixed geometrical position in the document. This position is specified relative to the complete document and the textflow is given through the insertionMode parameter.

```csharp
public bool Add(BarcodeFrame barcodeFrame, Point location, FrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(barcodeFrame As BarcodeFrame, location As Point, insertionMode As FrameInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| barcodeFrame | Specifies the barcode and its frame to add. |
| location | Specifies the location, in twips, at which the barcode is to be inserted. |
| insertionMode | Specifies how the text flow is handled. It can be one of the following values of the [FrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/frameinsertionmode/enumeration/llms-full.txt) enumeration:  \| Value \| Meaning \| \| AboveTheText \| The barcode is inserted at a certain geometrical location above the text. This means that the barcode overwrites the text. \| \| BelowTheText \| The barcode is inserted at a certain geometrical location below the text. This means that the text overwrites the barcode. \| \| DisplaceCompleteLines \| The text stops at the top and continues at the bottom of the barcode. \| \| DisplaceText \| The text flows around the barcode and empty areas at the left and right side are filled. \| \| Other Vaues \| All other values cannot be used with the BarcodeCollection.Add method. \| |
|---|

#### Add(BarcodeFrame, FrameInsertionMode)

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

```csharp
public bool Add(BarcodeFrame barcodeFrame, FrameInsertionMode insertionMode);
```

```vbnet
Public Function Add(barcodeFrame As BarcodeFrame, insertionMode As FrameInsertionMode) As Boolean
```

| Parameter | Description |
|---|---|
| barcodeFrame | Specifies the barcode and its frame to add. |
| insertionMode | Specifies how the text flow is handled. It can be one of the following values of the [FrameInsertionMode](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/frameinsertionmode/enumeration/llms-full.txt) enumeration:  \| Value \| Meaning \| \| AboveTheText \| The barcode is inserted at a certain geometrical location above the text. This means that the barcode overwrites the text. \| \| BelowTheText \| The barcode is inserted at a certain geometrical location below the text. This means that the text overwrites the barcode. \| \| DisplaceCompleteLines \| The text stops at the top and continues at the bottom of the barcode. \| \| DisplaceText \| The text flows around the barcode and empty areas at the left and right side are filled. \| \| Other Vaues \| All other values cannot be used with the BarcodeCollection.Add method. \| |
|---|

### Return Value

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

### Examples

The following example adds an item to the barcode collection.

```csharp
if (!barcodeCollection.Add(new TXTextControl.DataVisualization.BarcodeFrame("Approved"), -1))
{
    throw new InvalidOperationException("The item could not be inserted.");
}
```

```vbnet
If Not barcodeCollection.Add(New TXTextControl.DataVisualization.BarcodeFrame("Approved"), -1) Then
    Throw New InvalidOperationException("The item could not be inserted.")
End If
```

---

## Nearby

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