Condividi tramite


Metodo TextSelection.MoveToLineAndOffset

Sposta il punto attivo nella posizione specificata.

Spazio dei nomi:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Sintassi

'Dichiarazione
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
)

Parametri

  • Line
    Tipo: Int32

    Obbligatorio. Numero di riga su cui spostarsi, a partire da uno. Line potrebbe anche essere una delle costanti da vsGoToLineOptions.

  • Offset
    Tipo: Int32

    Obbligatorio. Posizione individuata dal numero di caratteri dall'inizio della riga, partendo da 1.

  • Extend
    Tipo: Boolean

    Parametro facoltativo. Impostazione predefinita = false. Valore Boolean che determina se estendere o meno la selezione corrente. Se Extend è true, l'estremità attiva della selezione viene spostata nella posizione, mentre l'estremità di ancoraggio non viene spostata. In caso contrario, entrambe le estremità verranno spostate nella posizione specificata. L'argomento è valido esclusivamente per l'oggetto TextSelection.

Note

Se il valore di Offset si trova oltre l'ultimo carattere della riga, il documento viene spostato alla fine della riga.

Esempi

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

TextSelection Interfaccia

Spazio dei nomi EnvDTE