TextSelection.MoveToPoint メソッド
更新 : 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
アクセス許可
- 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。