共用方式為


TextSelection.MoveToLineAndOffset 方法

將作用點移至指定的位置。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
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
)

參數

  • Offset
    型別:System.Int32
    必要項。在行裡面從 1 開始的字元索引。
  • Extend
    型別:System.Boolean
    選擇項。預設值 = false。用來擴充目前選取範圍的布林值。如果 Extend 為 true,那麼在錨定端保留在原來的位置時,選取範圍的作用端點會移至目前選取位置。否則,兩端都會移動至指定的位置。這個引數只可套用至 TextSelection 物件。

備註

如果 Offset 的值超出了該行的最後一個字元,文件將會移至該行的結尾。

範例

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 安全性

請參閱

參考

TextSelection 介面

EnvDTE 命名空間