TextRanges Interface
Collapse the table of content
Expand the table of content

TextRanges Interface

Contains a TextRange object for each of the tagged subexpressions from a search pattern. TextRanges is also used to find where a box selection intersects each line of text.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

public interface TextRanges : IEnumerable

The TextRanges type exposes the following members.

Public propertyCountGets a value indicating the number of objects in the collection.
Public propertyDTEGets the top-level extensibility object.
Public propertyParentGets the immediate parent object of a TextRanges collection.

Public methodGetEnumeratorGets an enumeration for items in a collection.
Public methodItemReturns a TextRange object in a TextRanges collection.

A TextRanges collection is returned from a search operation when the search pattern is a regular expression with tagged subexpressions. The TextRanges collection contains a TextRange object for each of the tagged subexpressions.

Also, TextRanges are used to get box selections from the TextSelection object if you need to determine where the box selection intersects each line.

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 ("*/");
© 2015 Microsoft