TextBox.GetCharacterIndexFromPoint(Point, Boolean) TextBox.GetCharacterIndexFromPoint(Point, Boolean) TextBox.GetCharacterIndexFromPoint(Point, Boolean) Method

定义

返回最接近指定点的字符的索引,该索引从零开始。Returns the zero-based index of the character that is closest to the specified point.

public:
 int GetCharacterIndexFromPoint(System::Windows::Point point, bool snapToText);
public int GetCharacterIndexFromPoint (System.Windows.Point point, bool snapToText);
member this.GetCharacterIndexFromPoint : System.Windows.Point * bool -> int

参数

point
Point Point Point

TextBox 坐标空间中一个要为其返回索引的点。A point in TextBox coordinate-space for which to return an index.

snapToText
Boolean Boolean Boolean

如果指定点处没有字符,则 true 将返回最近的索引,false 将返回 -1。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.

返回

最接近指定点的字符的索引;如果找不到有效的索引,则为 -1。The index of the character that is closest to the specified point, or -1 if no valid index can be found.

适用于

另请参阅