Condividi tramite


TextRanges Interface

Definition

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.

public interface class TextRanges : System::Collections::IEnumerable
[System.Runtime.InteropServices.Guid("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")]
[System.Runtime.InteropServices.TypeLibType(4160)]
public interface TextRanges : System.Collections.IEnumerable
[System.Runtime.InteropServices.Guid("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")]
public interface TextRanges : System.Collections.IEnumerable
[<System.Runtime.InteropServices.Guid("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")>]
[<System.Runtime.InteropServices.TypeLibType(4160)>]
type TextRanges = interface
    interface IEnumerable
[<System.Runtime.InteropServices.Guid("B6422E9C-9EFD-4F87-BDDC-C7FD8F2FD303")>]
type TextRanges = interface
    interface IEnumerable
Public Interface TextRanges
Implements IEnumerable
Attributes
Implements

Examples

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 ("*/");  
    }  
}  

Remarks

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.

Properties

Count

Gets a value indicating the number of objects in the collection.

DTE

Gets the top-level extensibility object.

Parent

Gets the immediate parent object of a TextRanges collection.

Methods

GetEnumerator()

Gets an enumeration for items in a collection.

Item(Object)

Returns a TextRange object in a TextRanges collection.

Applies to