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 値の 1 つ。

返品

要求された方向の次の挿入位置を識別する TextPointer 。次の挿入位置が見つからない場合は null

次の例では、このメソッドの使用方法を示します。 この例では、GetNextInsertionPosition メソッドを使用してコンテンツ要素の境界を走査し、指定された 2 つのParagraph インスタンス間に存在するTextPointer要素の数をカウントします。

// 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 タグ間 (つまり、前の段落の終了タグと次の段落の開始タグの間) の位置です。

適用対象

こちらもご覧ください