Export (0) Print
Expand All

TextSelection.Delete Method

Deletes the selected text.

Namespace: EnvDTE
Assembly: EnvDTE (in envdte.dll)

void Delete (
	[OptionalAttribute] [InAttribute] int Count
)
void Delete (
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ int Count
)
function Delete (
	Count : int
)

Parameters

Count

Optional. Represents the number of characters to delete.

Delete deletes the selected text without first copying it to the clipboard. If no text is selected, then Delete deletes Count characters to the right of the active end point. If Count is negative, then Delete performs like the DeleteLeft.

Public objSel As TextSelection = DTE.ActiveDocument.Selection

Sub DeleteExample()
   ' Before running this example, open a text document.
   ' Perform operations on the text.
   objSel.StartOfDocument(False)
   Position(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn, 4)
   objSel.Copy()
   Position(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, 4)
   objSel.Cut()
   Position(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, 4)
   objSel.Delete()
   Position(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, 4)
   objSel.DeleteLeft(6)
   objSel.DestructiveInsert("NEW TEXT")
End Sub

Sub Position(ByVal pos As vsStartOfLineOptions, ByVal ipos As Integer)
   ' Moves the insertion point down to the beginning of the next line, 
   ' then highlights the right-most four characters.
   objSel.LineDown()
   objSel.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
   objSel.CharRight(True, 4)
End Sub

Community Additions

ADD
Show:
© 2014 Microsoft