TextPointer.GetNextInsertionPosition(LogicalDirection) メソッド

定義

指定された論理方向の次の挿入位置への TextPointer を返します。Returns a TextPointer to the next insertion position in the specified logical direction.

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 値のいずれか。One of the LogicalDirection values that specifies the logical direction in which to search for the next insertion position.

戻り値

指定した方向の次の挿入位置を識別する TextPointer。次の挿入位置が見つからない場合は nullA TextPointer that identifies the next insertion position in the requested direction, or null if no next insertion position can be found.

このメソッドの使用例を次に示します。The following example demonstrates a use for this method. この例ではGetNextInsertionPosition 、メソッドを使用して、指定したTextPointer 2 つのParagraphインスタンスの間に存在する要素の数をカウントするために、コンテンツ要素の境界を走査します。The example uses the GetNextInsertionPosition method to traverse content element boundaries in order to count the number of Paragraph elements present between two specified TextPointer instances.

// 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.

注釈

挿入位置は、関連付けられているコンテンツのセマンティックルールを破壊することなく、新しいコンテンツを追加できる位置です。An insertion position is a position where new content may be added without breaking any semantic rules for the associated content. 実際には、挿入位置は、キャレットが配置されているコンテンツ内の任意の場所にあります。In practice, an insertion position is anywhere in content where a caret may be positioned. 挿入位置ではないTextPointer有効な位置の例として、隣接Paragraphする2つのタグ (つまり、前の段落の終了タグと次の段落の開始タグの間) の位置があります。An example of a valid TextPointer position that is not an insertion position is the position between two adjacent Paragraph tags (that is, between the closing tag of the preceding paragraph and the opening tag of the next paragraph).

適用対象

こちらもご覧ください