# SubTextPartCollection.GetItem Method

> Gets a particular subtextpart from the collection.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 23.0
- **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 > SubTextPartCollection.GetItem Method
- **1078 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/getitem-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/getitem-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/getitem-method/llms-full.txt

---

### Description

Gets a particular subtextpart from the collection.

### Syntax

#### GetItem()

Gets the subtextpart at the current text input position. If there is more than one textpart at the current input position the textpart with the highest level is returned.

```csharp
public SubTextPart GetItem();
```

```vbnet
Public Function GetItem() As SubTextPart
```

#### GetItem(string)

Gets the subtextpart with the specified name. The method returns null, if such a textpart does not exist. If more than one textpart with this name exists, the first found textpart is returned.

```csharp
public SubTextPart GetItem(string name);
```

```vbnet
Public Function GetItem(name As String) As SubTextPart
```

| Parameter | Description |
|---|---|
| name | Specifies the textpart's name set with the Name property. The method returns null if a textpart with the specified name does not exist. |

#### GetItem(int)

Gets the subtextpart with the specified id. The method returns null, if such a textpart does not exist. If more than one textpart with this id exists, the first found textpart is returned.

```csharp
public SubTextPart GetItem(int id);
```

```vbnet
Public Function GetItem(id As Integer) As SubTextPart
```

| Parameter | Description |
|---|---|
| id | Specifies the textpart's identifier. The method returns null if a textpart with the specified identifier does not exist. |

### Return Value

The return value is null, if a subtextpart with the specified parameters could not be found. Otherwise, it is an object of the type [SubTextPart](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpart/llms-full.txt).

### Examples

The following example retrieves a named document region and scrolls it into view.

```csharp
textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
SubTextPartCollection parts = textControl.SubTextParts;
SubTextPart customer = new("CustomerName", 10) { Data = @"{""category"":""customer""}" };
parts.Add(customer);
SubTextPart part = parts.GetItem(10);
part?.ScrollTo();
```

```vbnet
textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim parts As SubTextPartCollection = textControl.SubTextParts
Dim customer As New SubTextPart("CustomerName", 10) With { .Data = "{""category"":""customer""}" }
parts.Add(customer)
Dim part As SubTextPart = parts.GetItem(10)
If part IsNot Nothing Then part.ScrollTo()
```

---

## Nearby

- **Previous:** [SubTextPartCollection.GetEnumerator Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/getenumerator-method/llms-full.txt)
- **Next:** [SubTextPartCollection.IsSynchronized Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/issynchronized-property/llms-full.txt)
