TextSelection::MoveToLineAndOffset Method (Int32, Int32, Boolean)
Visual Studio 2015
Moves the active point to the given position.
Assembly: EnvDTE (in EnvDTE.dll)
Parameters
- Line
-
Type:
System::Int32
Required. The line number to move to, beginning at one. Line may also be one of the constants from vsGoToLineOptions.
- 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.
If the value of Offset is beyond the last character of the line, the document moves to the end of the line.
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
Show: