ITextRange.GetIndex method

Applies to Windows and Windows Phone

Retrieves the story index of the text unit (word, line, sentence, paragraph, and so on) at the starting character position of the text range.

Syntax


int GetIndex(
  TextRangeUnit unit
)

Parameters

unit

Type: TextRangeUnit

The text unit that is indexed.

Return value

Type: System.Int32 [.NET] | int32 [C++]

The index value. The value is zero if unit does not exist.

Remarks

The first unit in a story has an index value of 1. The index of a unit is the same for all character positions from the position immediately preceding the unit, up to the last character in the unit.

For a text range at the end of a story, the index retrieved by GetIndex indicates the number of units in the story, such as the number of words, lines, objects, and so on.

The index value returned by the GetIndex method is not valid if the text is subsequently edited. Be careful when using retrieved index values, especially if you store the values for a significant length of time.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Text
Windows::UI::Text [C++]

Metadata

Windows.winmd

See also

ITextRange
ITextRange.SetIndex

 

 

Show:
© 2014 Microsoft