# ImageCollection.GetItem Method

> Gets a particular image from the collection.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 15.1
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WinForms.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 Windows Forms > Reference > TXTextControl > ImageCollection.GetItem Method
- **1073 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imagecollection/getitem-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imagecollection/getitem-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imagecollection/getitem-method/llms-full.txt

---

### Description

Gets a particular image from the collection.

### Syntax

#### GetItem()

Gets the image selected by the user.

```csharp
public Image GetItem();
```

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

#### GetItem(int)

Gets the image with the specified identifier. An identifier can be set with the [Image.ID](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/framebase/id-property/llms-full.txt) property.

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

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

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

#### GetItem(string)

Gets the image with the specified name. A name can be set with the [Image.Name](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/framebase/name-property/llms-full.txt) property.

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

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

| Parameter | Description |
|---|---|
| name | Specifies the image's name. The method returns null if an image with the specified name does not exist. |

### Return Value

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

### Examples

The following example retrieves the image at the current input position and supplies missing alternative text.

```csharp
TXTextControl.Image logo = new() { FileName = @"Images\company-logo.png", Name = "CompanyLogo", DescriptiveText = "Company logo" };
textControl.Images.Add(logo, -1);
TXTextControl.Image image = textControl.Images.GetItem();
if (image != null && string.IsNullOrWhiteSpace(image.DescriptiveText))
{
    image.DescriptiveText = "Company logo";
}
```

```vbnet
Dim logo As New TXTextControl.Image() With { .FileName = "Images\company-logo.png", .Name = "CompanyLogo", .DescriptiveText = "Company logo" }
textControl.Images.Add(logo, -1)
Dim image As TXTextControl.Image = textControl.Images.GetItem()
If image IsNot Nothing AndAlso String.IsNullOrWhiteSpace(image.DescriptiveText) Then
    image.DescriptiveText = "Company logo"
End If
```

---

## Nearby

- **Previous:** [ImageCollection.ExportFilters Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imagecollection/exportfilters-property/llms-full.txt)
- **Next:** [ImageCollection.ImportFilters Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/imagecollection/importfilters-property/llms-full.txt)
