共用方式為


TextPointer.GetNextInsertionPosition(LogicalDirection) 方法

定義

TextPointer 傳回至所指定邏輯方向中的下一個插入位置。

public:
 System::Windows::Documents::TextPointer ^ GetNextInsertionPosition(System::Windows::Documents::LogicalDirection direction);
public System.Windows.Documents.TextPointer GetNextInsertionPosition (System.Windows.Documents.LogicalDirection direction);
member this.GetNextInsertionPosition : System.Windows.Documents.LogicalDirection -> System.Windows.Documents.TextPointer
Public Function GetNextInsertionPosition (direction As LogicalDirection) As TextPointer

參數

direction
LogicalDirection

其中一個 LogicalDirection 值,這個值會指定將在哪一個邏輯方向搜尋下一個插入位置。

傳回

TextPointer

TextPointer,識別所要求方向中下一個插入位置,或者若找不到下一個插入位置的話,則為 null

範例

下列範例示範這個方法的用法。 此範例會 GetNextInsertionPosition 使用 方法來周遊內容專案界限,以計算兩個指定 TextPointer 實例之間存在的元素數目 Paragraph

// This method returns the number of pagragraphs between two
// specified TextPointers.
int GetParagraphCount(TextPointer start, TextPointer end)
{
    int paragraphCount = 0;
 
    while (start != null && start.CompareTo(end) < 0)
    {
        Paragraph paragraph = start.Paragraph;
 
        if (paragraph != null)
        {
            paragraphCount++;
 
            // Advance start to the end of the current paragraph.
            start = paragraph.ContentEnd;
         }
 
         // Use the GetNextInsertionPosition method to skip over any interceding
         // content element tags.
         start = start.GetNextInsertionPosition(LogicalDirection.Forward);
     } // End while.
 
         return paragraphCount;
}  // End GetParagraphCount.
' This method returns the number of pagragraphs between two
' specified TextPointers.
Private Function GetParagraphCount(ByVal start As TextPointer, ByVal [end] As TextPointer) As Integer
    Dim paragraphCount As Integer = 0

    Do While start IsNot Nothing AndAlso start.CompareTo([end]) < 0
        Dim paragraph As Paragraph = start.Paragraph

        If paragraph IsNot Nothing Then
            paragraphCount += 1

            ' Advance start to the end of the current paragraph.
            start = paragraph.ContentEnd
        End If

        ' Use the GetNextInsertionPosition method to skip over any interceding
        ' content element tags.
        start = start.GetNextInsertionPosition(LogicalDirection.Forward)

    Loop ' End while.

    Return paragraphCount

End Function ' End GetParagraphCount.

備註

插入位置 是一個位置,可在不中斷相關內容的任何語意規則的情況下新增新內容。 實際上,插入位置是在內容中可放置插入號的位置。 不是插入位置的有效 TextPointer 位置範例是兩個相鄰 Paragraph 標籤 (之間的位置,也就是前一個段落的結束記號與下一個段落的開頭標記) 。

適用於

另請參閱