Freigeben über


TextSelection.TextRanges Property

Definition

Gets a TextRanges collection with one TextRange object for each line or partial line in the selection.

public:
 property EnvDTE::TextRanges ^ TextRanges { EnvDTE::TextRanges ^ get(); };
[System.Runtime.InteropServices.DispId(56)]
public EnvDTE.TextRanges TextRanges { [System.Runtime.InteropServices.DispId(56)] get; }
[<System.Runtime.InteropServices.DispId(56)>]
[<get: System.Runtime.InteropServices.DispId(56)>]
member this.TextRanges : EnvDTE.TextRanges
Public ReadOnly Property TextRanges As TextRanges

Property Value

A TextRanges collection.

Attributes

Examples

Sub TextRangesExample()  
   ' Before running this example, open a code document.  
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection  
   MsgBox("Startpoint line: " & (objSel.TextRanges.Item(1).StartPoint.Line) & vbCr & "Endpoint line: " & (objSel.TextRanges.Item(1).EndPoint.Line))  
End Sub  

Remarks

For each line in the text selection, regardless of its current mode, a TextRange object represents the virtual portion of the line in the selection. When the selection mode is Stream, the TextRange objects represent only the text that is in the selection. If some lines are longer than others, you get ranges only for lines that actually contain text.

Each time the TextRanges collection is retrieved from the text selection, the prior contents are lost.

Applies to