# TextPartCollection.Activate Method

> Sets the input focus to the specified text part. If the activated text part is not in the visible part of the document, the document is scrolled.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 22.0
- **Namespace:** `TXTextControl.Web`
- **Package:** `TXTextControl.Web` (assembly `TXTextControl.Web.DocumentEditor.dll`, from nuget.org, the private NuGet feed or Text Control Offline Packages)
- **Path:** TX Text Control .NET Server > Reference > TXTextControl.Web > TextPartCollection.Activate Method
- **581 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textpartcollection/activate-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textpartcollection/activate-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textpartcollection/activate-method/llms-full.txt

---

### Description

Sets the input focus to the specified text part. If the activated text part is not in the visible part of the document, the document is scrolled.

### Syntax

```csharp
public bool Activate(IFormattedText textPart);
```

```vbnet
Public Function Activate(textPart As IFormattedText) As Boolean
```

### Parameters

| Parameter | Description |
|---|---|
| textPart | Specifies the text part to activate. Must be an object of the type [Web.MainText](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/maintext/llms-full.txt), [Web.TextFrame](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textframe/llms-full.txt) or [Web.HeaderFooter](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/headerfooter/llms-full.txt). |

### Return Value

The return value is true, if the specified text part could be activated. Otherwise it is false.

### Examples

The following example activates the first available web text part so subsequent editor commands target that part.

```csharp
foreach (TXTextControl.Web.IFormattedText textPart in textPartCollection)
{
    if (textPartCollection.Activate(textPart))
    {
        Console.WriteLine("The text part is active.");
        break;
    }
}
```

```vbnet
For Each textPart As TXTextControl.Web.IFormattedText In textPartCollection
    If textPartCollection.Activate(textPart) Then
        Console.WriteLine("The text part is active.")
        Exit For
    End If
Next
```

---

## Nearby

- **Previous:** [TextPartCollection Class](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textpartcollection/llms-full.txt)
- **Next:** [Classes by Task](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/dotnet-api/tasks/llms-full.txt)
