TX Text Control .NET for WPF

GetItem Method

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

Description

Gets a particular character from the collection specified through a certain geometrical position.

Syntax

public TextChar GetItem(Point location, bool getNearest);

Parameters

ParameterDescription
location

Specifies the character's location. The point must be specified in pixels with an origin at the top left corner of the control.

getNearest

Specifies whether the nearest character is returned. If this parameter is set to true, the nearest character is returned. Otherwise, if set to false, a character is only returned, if the specified location is inside the bounding rectangle of an existing character.

Return Value

The return value is null, if a character could not be found. Otherwise, it is an object of the type TextChar.

Examples

The following example works with text chars in the current document by using TextCharCollection.get_Item.

TextCharCollection textCharCollection = textControl.TextChars;
textControl.Text = "Quarterly results\nRevenue increased by 12%.";

var result = textCharCollection.GetItem(new System.Drawing.Point(20, 20), true);
Console.WriteLine($"Get Item result: {result}");