次の方法で共有


TextRanges インターフェイス

検索パターンの各タグ付き部分式に対する TextRange オブジェクトを含みます。 TextRanges は、ボックスの選択項目とテキストの各行との交差部分を見つけるためにも使用されます。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
<GuidAttribute("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")> _
Public Interface TextRanges _
    Inherits IEnumerable
[GuidAttribute("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")]
public interface TextRanges : IEnumerable
[GuidAttribute(L"B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")]
public interface class TextRanges : IEnumerable
[<GuidAttribute("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")>]
type TextRanges =  
    interface 
        interface IEnumerable 
    end
public interface TextRanges extends IEnumerable

TextRanges 型で公開されるメンバーは以下のとおりです。

プロパティ

  名前 説明
パブリック プロパティ Count コレクション内のオブジェクトの数を示す値を取得します。
パブリック プロパティ DTE トップレベルの機能拡張オブジェクトを取得します。
パブリック プロパティ Parent TextRanges コレクションの直接の親オブジェクトを取得します。

このページのトップへ

メソッド

  名前 説明
パブリック メソッド GetEnumerator コレクション内の項目の列挙子を取得します。
パブリック メソッド Item TextRanges コレクション内の TextRange オブジェクトを返します。

このページのトップへ

解説

TextRanges コレクションは、検索パターンがタグ付き部分式を持つ正規表現である場合に、検索操作の結果として返されます。 TextRanges コレクションには、各タグ付き部分式に対する TextRange オブジェクトが含まれます。

また、ボックスの選択項目と各行との交差部分を決定する必要がある場合、TextRanges は TextSelection オブジェクトからボックスの選択項目を取得するためにも使用されます。

Sub TextRangeExample(ByVal dte As EnvDTE.DTE)
    Dim objTxtSel As TextSelection
    Dim colRanges As TextRanges
    Dim objRange As TextRange
    Dim objEP As EditPoint

    objTxtSel = dte.ActiveDocument.Selection
    colRanges = objTxtSel.TextRanges
    For Each objRange In colRanges
        objRange.StartPoint.Insert("/*")
        objRange.EndPoint.Insert("*/")
    Next
End Sub
public void TextRangeExample(_DTE dte)
{
    TextSelection ts;
    TextRanges trs;

    ts = (TextSelection)dte.ActiveDocument.Selection;
    trs = ts.TextRanges;
    MessageBox.Show (trs.Count.ToString ());
    foreach (TextRange tr in trs)
    {
        tr.StartPoint.Insert ("/*");
        tr.EndPoint.Insert ("*/");
    }
}

参照

関連項目

EnvDTE 名前空間