TextSelection.MoveToLineAndOffset Method

Moves the active point to the given position.

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

Syntax

'Declaration
Sub MoveToLineAndOffset ( _
    Line As Integer, _
    Offset As Integer, _
    Extend As Boolean _
)
void MoveToLineAndOffset(
    int Line,
    int Offset,
    bool Extend
)
void MoveToLineAndOffset(
    [InAttribute] int Line, 
    [InAttribute] int Offset, 
    [InAttribute] bool Extend
)
abstract MoveToLineAndOffset : 
        Line:int * 
        Offset:int * 
        Extend:bool -> unit
function MoveToLineAndOffset(
    Line : int, 
    Offset : int, 
    Extend : boolean
)

Parameters

  • Offset
    Type: System.Int32

    Required. The character index position in the line, starting at one.

  • Extend
    Type: System.Boolean

    Optional. Default = false. A Boolean value to extend the current selection. If Extend is true, then the active end of the selection moves to the location, while the anchor end remains where it is. Otherwise, both ends are moved to the specified location. This argument applies only to the TextSelection object.

Remarks

If the value of Offset is beyond the last character of the line, the document moves to the end of the line.

Examples

Sub MoveToLineAndOffsetExample()
    ' Before running this example, open a text document.
    Dim objSel As TextSelection = DTE.ActiveDocument.Selection

    ' Move to the beginning of the document so we can iterate over the 
    ' whole thing.
    objSel.StartOfDocument()
    While objSel.FindPattern("#if _DEBUG")
        ' If we found the beginning of a debug-only section, save the 
        ' position.
        Dim lStartLine As Long = objSel.TopPoint.Line
        Dim lStartColumn As Long = objSel.TopPoint.LineCharOffset

        ' Look for the end.
        If objSel.FindPattern("#endif") Then
            ' Select the entire section and outline it.
            objSel.SwapAnchor()
            objSel.MoveToLineAndOffset(lStartLine, lStartColumn, True)
            objSel.OutlineSection()
            objSel.LineDown()
        End If
    End While
End Sub

.NET Framework Security

See Also

Reference

TextSelection Interface

EnvDTE Namespace