Compartir a través de


TextSelection.MoveToLineAndOffset(Int32, Int32, Boolean) Method

Definition

Moves the active point to the given position.

void MoveToLineAndOffset(int Line, int Offset, bool Extend = false);
[System.Runtime.InteropServices.DispId(39)]
public void MoveToLineAndOffset (int Line, int Offset, bool Extend = false);
[<System.Runtime.InteropServices.DispId(39)>]
abstract member MoveToLineAndOffset : int * int * bool -> unit
Public Sub MoveToLineAndOffset (Line As Integer, Offset As Integer, Optional Extend As Boolean = false)

Parameters

Line
Int32

Required. The line number to move to, beginning at one. Line may also be one of the constants from vsGoToLineOptions.

Offset
Int32

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

Extend
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.

Attributes

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  

Remarks

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

Applies to