Export (0) Print
Expand All

RichTextBox.GetPositionFromPoint Method

Returns a TextPointer that points to the insertion point closest to the specified position.

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

public TextPointer GetPositionFromPoint(
	Point point,
	bool snapToText
)

Parameters

point
Type: System.Windows.Point

A Point object specifying the position to retrieve a TextPointer for.

snapToText
Type: System.Boolean

If true, this method always returns a TextPointer specifying the closest insertion position for the Point specified, regardless or whether or not the supplied Point is inside a character's bounding box.

If false, this method returns null if the specified Point does not fall within any character bounding box.

Return Value

Type: System.Windows.Documents.TextPointer
A TextPointer specifying the closest insertion position for the supplied point, or null if snapToText is false and the supplied Point is not within any character's bounding box. Note that the TextPointer returned is usually the position between two characters. Use the LogicalDirection property of the returned TextPointer to determine which of the two characters the TextPointer corresponds to.

ExceptionCondition
InvalidOperationException

Raised if layout information for the RichTextBox is not current.

RichTextBox uses a standard coordinate system with the origin located at the upper-left corner of the RichTextBox.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft