TX Text Control .NET for Windows Forms

GetItem Method

Method|Introduced in 15.1
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Gets a particular image from the collection.

Syntax

GetItem()

Gets the image selected by the user.

public Image GetItem();

GetItem(int)

Gets the image with the specified identifier. An identifier can be set with the Image.ID property.

public Image GetItem(int id);
ParameterDescription
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 property.

public Image GetItem(string name);
ParameterDescription
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.

Examples

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

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";
}