TextBox.GetCharacterIndexFromPoint(Point, Boolean) Method

Definition

Returns the zero-based index of the character that is closest to the specified point.

C#
public int GetCharacterIndexFromPoint(System.Windows.Point point, bool snapToText);

Parameters

point
Point

A point in TextBox coordinate-space for which to return an index.

snapToText
Boolean

true to return the nearest index if there is no character at the specified point; false to return -1 if there is no character at the specified point.

Returns

The index of the character that is closest to the specified point, or -1 if no valid index can be found.

Applies to

Producto Versiones
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also