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。次の挿入位置が見つからない場合は null

次の例では、このメソッドの使用方法を示します。 この例では、 メソッドをGetNextInsertionPosition使用してコンテンツ要素の境界を走査し、指定された TextPointer 2 つのインスタンス間に存在する要素の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 位置の例は、2 つの隣接する Paragraph タグ間の位置 (つまり、前の段落の終了タグと次の段落の開始タグの間) です。

適用対象

こちらもご覧ください