更新:2007 年 11 月
将活动点移到给定位置。
命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)
语法
声明
Sub MoveToPoint ( _
    Point As TextPoint, _
    Extend As Boolean _
)
用法
Dim instance As TextSelection
Dim Point As TextPoint
Dim Extend As Boolean
instance.MoveToPoint(Point, Extend)
void MoveToPoint(
    TextPoint Point,
    bool Extend
)
void MoveToPoint(
    [InAttribute] TextPoint^ Point, 
    [InAttribute] bool Extend
)
function MoveToPoint(
    Point : TextPoint, 
    Extend : boolean
)
参数
- Point 
 类型:EnvDTE.TextPoint- 必需。将字符移动到的位置。 
- Extend 
 类型:System.Boolean- 可选。默认值为 false。确定是否扩展当前的选定范围。如果 Extend 为 true,则选定内容的活动端会移到该位置,而定位端保留在原地。否则,两端都将移动到指定位置。此参数仅适用于 TextSelection 对象。 
示例
Sub MoveToPointExample()
    ' Before running this example, open a text document.
    Dim objSel As TextSelection = DTE.ActiveDocument.Selection
    If objSel.IsEmpty Then
        ' If there is no text selected, swap the words before and after 
        ' the insertion point. We begin by selecting the word before 
        ' the insertion point.
        objSel.WordLeft(True)
        If Not objSel.IsEmpty Then
            ' We can continue only if the selection was not already at 
            ' the beginning of the document.
            Dim strBefore As String = objSel.Text
            ' The text is saved in strBefore; now delete it and move 
            ' past the following word.
            objSel.Delete()
            objSel.WordRight(True)
            If objSel.Text.StartsWith(" ") Or objSel.Text.StartsWith(Microsoft.VisualBasic.ControlChars.Tab) Then
                ' The previous call to WordRight may have skipped some 
                ' white space instead of an actual word. In that case, 
                ' we should call it again.
                objSel.WordRight(True)
            End If
            ' Insert the new text at the end of the selection.
            objSel.Insert(strBefore, vsInsertFlags.vsInsertFlagsInsertAtEnd)
        End If
    Else
        ' If some text is selected, replace the following word with the 
        ' selected text.
        Dim strSelected As String = objSel.Text
        objSel.MoveToPoint(objSel.BottomPoint)
        objSel.WordRight(True)
        If objSel.Text.StartsWith(" ") Or objSel.Text.StartsWith(Microsoft.VisualBasic.ControlChars.Tab) Then
            ' The previous call to WordRight may have skipped some 
            ' white space instead of an actual word. In that case, we 
            ' should call it again.
            objSel.WordRight(True)
        End If
        ' Insert the text, overwriting the existing text and leaving 
        ' the selection containing the inserted text.
        objSel.Insert(strSelected, vsInsertFlags.vsInsertFlagsContainNewText)
    End If
End Sub
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。