# TextPartCollection.GetItem Method

> Gets a certain text part from the collection.

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

---

### Description

Gets a certain text part from the collection.

### Syntax

#### GetItem()

Gets the text part with the input focus.

```csharp
public object GetItem();
```

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

#### GetItem(out Point)

Gets the text part with the input focus informing about the offset of the text part in the TextControl's client area.

```csharp
public object GetItem(out Point clientOffset);
```

```vbnet
Public Function GetItem(ByRef clientOffset As Point) As Object
```

| Parameter | Description |
|---|---|
| clientOffset | Retrieves the text part's offset, in pixels, in the TextControl's client area. |

#### GetItem(Point, out Point)

Gets the text part at the specified geometric location.

```csharp
public object GetItem(Point location, out Point clientOffset);
```

```vbnet
Public Function GetItem(location As Point, ByRef clientOffset As Point) As Object
```

| Parameter | Description |
|---|---|
| location | Specifies a location where to search for a text part. The point must be specified in pixels with an origin at the top left corner of the control. |
| clientOffset | Retrieves the text part's offset, in pixels, in the TextControl's client area. |

### Return Value

The return value is the found text part, which is either the text part with the input focus or the text part at the specified location. It can be an object of the type [MainText](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/maintext/llms-full.txt), [TextFrame](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textframe/llms-full.txt), [FootnoteSection](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/footnotesection/llms-full.txt) or [HeaderFooter](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/headerfooter/llms-full.txt). All of these objects implement the [IFormattedText](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/iformattedtext/llms-full.txt) interface. The first and the second implementation return null, if there is no text part with the input focus. This can happen, if an image is selected, or if another application or component has the input focus.

### Examples

The following example works with text parts in the current document by using `TextPartCollection.GetItem`.

```csharp
TextPartCollection textPartCollection = textControl.TextParts;

var result = textPartCollection.GetItem();
Console.WriteLine($"Get Item result: {result}");
```

```vbnet
Dim textPartCollection As TextPartCollection = textControl.TextParts

Dim result = textPartCollection.GetItem()
Console.WriteLine($"Get Item result: {result}")
```

---

## Nearby

- **Previous:** [TextPartCollection.GetEnumerator Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textpartcollection/getenumerator-method/llms-full.txt)
- **Next:** [TextPartCollection.GetMainText Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textpartcollection/getmaintext-method/llms-full.txt)
