This documentation is archived and is not being maintained.

TextBox.GetCharacterIndexFromPoint Method

Returns the zero-based insertion index for the specified point.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public int GetCharacterIndexFromPoint(
	Point point,
	bool snapToText
)
You cannot use methods in XAML.

Parameters

point
Type: System.Windows.Point

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

snapToText
Type: System.Boolean

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

Return Value

Type: System.Int32
The insertion index for the specified point, or –1 if no valid insertion index can be found.

An insertion index references a position between characters; contrast with a character index, which references specific characters. Text that is N characters long has N+1 possible insertion indexes. An insertion index of M could mean the given point is in the right half of the character to the left of M, or on the left half of the point to the right of M.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Show: