# Selection.Load Method

> Exchanges the currently selected text with text in a certain format.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Namespace:** `TXTextControl`
- **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 > Selection.Load Method
- **3342 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selection/load-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selection/load-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selection/load-method/llms-full.txt

---

### Description

Exchanges the currently selected text with text in a certain format.

### Syntax

#### Load()

Opens a dialog box to select a file and exchanges the currently selected text with the text from that file.

```csharp
public Selection.DialogResult Load();
```

```vbnet
Public Function Load() As Selection.DialogResult
```

#### Load(StreamType)

Opens a dialog box to select a file in the specified format and exchanges the currently selected text with the text from that file.

```csharp
public Selection.DialogResult Load(StreamType streamType);
```

```vbnet
Public Function Load(streamType As StreamType) As Selection.DialogResult
```

| Parameter | Description |
|---|---|
| streamType | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/streamtype/enumeration/llms-full.txt) values. |

#### Load(string, StreamType)

Exchanges the currently selected text with text in the specified format. The new text is read from the specified file.

```csharp
public void Load(string path, StreamType streamType);
```

```vbnet
Public Sub Load(path As String, streamType As StreamType)
```

| Parameter | Description |
|---|---|
| path | Specifies a file from which the data is loaded. |
| streamType | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/streamtype/enumeration/llms-full.txt) values. |

#### Load(FileStream, StreamType)

Exchanges the currently selected text with text in the specified format. The new text is read from the specified file stream.

```csharp
public void Load(FileStream fileStream, StreamType streamType);
```

```vbnet
Public Sub Load(fileStream As FileStream, streamType As StreamType)
```

| Parameter | Description |
|---|---|
| fileStream | Specifies a file from which the data is loaded. The data is loaded from the stream's current position. |
| streamType | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/streamtype/enumeration/llms-full.txt) values. |

#### Load(byte\[\], BinaryStreamType)

Exchanges the currently selected text with text in the specified format. The new text is read from the specified byte array.

```csharp
public void Load(byte[] binaryData, BinaryStreamType binaryStreamType);
```

```vbnet
Public Sub Load(binaryData As Byte(), binaryStreamType As BinaryStreamType)
```

| Parameter | Description |
|---|---|
| binaryData | Specifies a byte array from which the data is loaded. |
| binaryStreamType | Specifies one of the [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/binarystreamtype/enumeration/llms-full.txt) values. |

#### Load(string, StringStreamType)

Exchanges the currently selected text with text in the specified format. The new text is read from the specified string.

```csharp
public void Load(string stringData, StringStreamType stringStreamType);
```

```vbnet
Public Sub Load(stringData As String, stringStreamType As StringStreamType)
```

| Parameter | Description |
|---|---|
| stringData | Specifies a string from which the data is loaded. |
| stringStreamType | Specifies one of the [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/stringstreamtype/enumeration/llms-full.txt) values. |

#### Load(StreamType, LoadSettings)

Opens a dialog box to select a file in the specified format and exchanges the currently selected text with the text from that file using the specified special settings.

```csharp
public Selection.DialogResult Load(StreamType streamType, LoadSettings loadSettings);
```

```vbnet
Public Function Load(streamType As StreamType, loadSettings As LoadSettings) As Selection.DialogResult
```

| Parameter | Description |
|---|---|
| streamType | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/streamtype/enumeration/llms-full.txt) values. |
| loadSettings | Specifies a [LoadSettings](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/loadsettings/llms-full.txt) object with additional information and settings for the load operation. |

#### Load(string, StreamType, LoadSettings)

Exchanges the currently selected text with text in the specified format. The new text is read from the specified file and loaded using the given special settings.

```csharp
public void Load(string path, StreamType streamType, LoadSettings loadSettings);
```

```vbnet
Public Sub Load(path As String, streamType As StreamType, loadSettings As LoadSettings)
```

| Parameter | Description |
|---|---|
| path | Specifies a file from which the data is loaded. |
| streamType | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/streamtype/enumeration/llms-full.txt) values. |
| loadSettings | Specifies a [LoadSettings](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/loadsettings/llms-full.txt) object with additional information and settings for the load operation. |

#### Load(FileStream, StreamType, LoadSettings)

Exchanges the currently selected text with text in the specified format. The new text is read from the specified file stream and loaded using the given special settings.

```csharp
public void Load(FileStream fileStream, StreamType streamType, LoadSettings loadSettings);
```

```vbnet
Public Sub Load(fileStream As FileStream, streamType As StreamType, loadSettings As LoadSettings)
```

| Parameter | Description |
|---|---|
| fileStream | Specifies a file from which the data is loaded. The data is loaded from the stream's current position. |
| streamType | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/streamtype/enumeration/llms-full.txt) values. |
| loadSettings | Specifies a [LoadSettings](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/loadsettings/llms-full.txt) object with additional information and settings for the load operation. |

#### Load(byte\[\], BinaryStreamType, LoadSettings)

Exchanges the currently selected text with text in the specified format. The new text is read from the specified byte array and loaded using the given special settings.

```csharp
public void Load(byte[] binaryData, BinaryStreamType binaryStreamType, LoadSettings loadSettings);
```

```vbnet
Public Sub Load(binaryData As Byte(), binaryStreamType As BinaryStreamType, loadSettings As LoadSettings)
```

| Parameter | Description |
|---|---|
| binaryData | Specifies a byte array from which the data is loaded. |
| binaryStreamType | Specifies one of the [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/binarystreamtype/enumeration/llms-full.txt) values. |
| loadSettings | Specifies a [LoadSettings](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/loadsettings/llms-full.txt) object with additional information and settings for the load operation. |

#### Load(string, StringStreamType, LoadSettings)

Exchanges the currently selected text with text in the specified format. The new text is read from the specified string and loaded using the given special settings.

```csharp
public void Load(string stringData, StringStreamType stringStreamType, LoadSettings loadSettings);
```

```vbnet
Public Sub Load(stringData As String, stringStreamType As StringStreamType, loadSettings As LoadSettings)
```

| Parameter | Description |
|---|---|
| stringData | Specifies a string from which the data is loaded. |
| stringStreamType | Specifies one of the [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/stringstreamtype/enumeration/llms-full.txt) values. |
| loadSettings | Specifies a [LoadSettings](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/loadsettings/llms-full.txt) object with additional information and settings for the load operation. |

### Return Value

The implementations which open a dialog box return a [Selection.DialogResult](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selection/dialogresult-enumeration/llms-full.txt) value.

### Examples

The following example formats the heading of a short document by using `Selection.Load`.

```csharp
textControl.Text = "Quarterly results\nRevenue increased by 12%.";
textControl.Select(0, 17);
Selection selection = textControl.Selection;

selection.Load(@"{\rtf1\ansi Sample document}", StringStreamType.RichTextFormat);
Console.WriteLine("Selection is ready for use.");
```

```vbnet
textControl.Text = "Quarterly results" & vbCrLf & "Revenue increased by 12%."
textControl.Select(0, 17)
Dim selection As Selection = textControl.Selection

selection.Load("{\rtf1\ansi Sample document}", StringStreamType.RichTextFormat)
Console.WriteLine("Selection is ready for use.")
```

### Remarks

The methods opening a dialog box are not available through the [Selection](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selection/llms-full.txt) object of a [ServerTextControl](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/llms-full.txt).

---

## Nearby

- **Previous:** [Selection.ListFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selection/listformat-property/llms-full.txt)
- **Next:** [Selection.ParagraphFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/selection/paragraphformat-property/llms-full.txt)
