Partager via


TextSelection Interface

Provides access to view-based editing operations and selected text.

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

Syntax

'Declaration
<GuidAttribute("1FA0E135-399A-4D2C-A4FE-D21E2480F921")> _
Public Interface TextSelection
[GuidAttribute("1FA0E135-399A-4D2C-A4FE-D21E2480F921")]
public interface TextSelection
[GuidAttribute(L"1FA0E135-399A-4D2C-A4FE-D21E2480F921")]
public interface class TextSelection
[<GuidAttribute("1FA0E135-399A-4D2C-A4FE-D21E2480F921")>]
type TextSelection =  interface end
public interface TextSelection

The TextSelection type exposes the following members.

Properties

  Name Description
Public property ActivePoint Gets the current endpoint of the selection.
Public property AnchorColumn Infrastructure. Microsoft Internal Use Only.
Public property AnchorPoint Gets the origin point of the selection.
Public property BottomLine Infrastructure. Microsoft Internal Use Only.
Public property BottomPoint Gets the point at the end of the selection.
Public property CurrentColumn Infrastructure. Microsoft Internal Use Only.
Public property CurrentLine Infrastructure. Microsoft Internal Use Only.
Public property DTE Gets the top-level extensibility object.
Public property IsActiveEndGreater Gets whether the active point is equal to the bottom point.
Public property IsEmpty Gets whether the anchor point is equal to the active point.
Public property Mode Sets or gets a value determining whether dragging the mouse selects in stream or block mode.
Public property Parent Gets the immediate parent object of a TextSelection object.
Public property Text Sets or gets the text selection.
Public property TextPane Gets the text pane that contains the text selection.
Public property TextRanges Gets a TextRanges collection with one TextRange object for each line or partial line in the selection.
Public property TopLine Infrastructure. Microsoft Internal Use Only.
Public property TopPoint Gets the top end of the selection.

Top

Methods

  Name Description
Public method Backspace Infrastructure. Microsoft Internal Use Only.
Public method Cancel Infrastructure. Microsoft Internal Use Only.
Public method ChangeCase Changes the case of the text selection.
Public method CharLeft Moves the object the specified number of characters to the left.
Public method CharRight Moves the object the specified number of characters to the right.
Public method ClearBookmark Clears any unnamed bookmarks in the current text buffer line.
Public method Collapse Collapses the text selection to the active point.
Public method Copy Copies the text selection to the clipboard.
Public method Cut Copies the text selection to the clipboard and deletes it from its original location.
Public method Delete Deletes the text selection.
Public method DeleteLeft Deletes a specified number of characters to the left of the active point.
Public method DeleteWhitespace Deletes the empty characters (white space) horizontally or vertically around the current location in the text buffer.
Public method DestructiveInsert Inserts text, overwriting the existing text.
Public method EndOfDocument Moves the object to the end of the document.
Public method EndOfLine Moves the object to the end of the current line.
Public method FindPattern Searches for the given pattern from the active point to the end of the document.
Public method FindText Searches for the given text from the active point to the end of the document.
Public method GotoLine Moves to the beginning of the indicated line and selects the line if requested.
Public method Indent Indents the selected lines by the given number of indentation levels.
Public method Insert Inserts the given string at the current insertion point.
Public method InsertFromFile Inserts the contents of the specified file at the current location in the buffer.
Public method LineDown Moves the insertion point of the text selection down the specified number of lines.
Public method LineUp Moves the insertion point of the text selection up the specified number of lines.
Public method MoveTo Infrastructure. Microsoft Internal Use Only.
Public method MoveToAbsoluteOffset Moves the active point to the given 1-based absolute character offset.
Public method MoveToDisplayColumn Moves the active point to the indicated display column.
Public method MoveToLineAndOffset Moves the active point to the given position.
Public method MoveToPoint Moves the active point to the given position.
Public method NewLine Inserts a line break character at the active point.
Public method NextBookmark Moves to the location of the next bookmark in the document.
Public method OutlineSection Creates an outlining section based on the current selection.
Public method PadToColumn Fills the current line in the buffer with empty characters (white space) to the given column.
Public method PageDown Moves the active point a specified number of pages down in the document, scrolling the view.
Public method PageUp Moves the active point a specified number of pages up in the document, scrolling the view.
Public method Paste Inserts the clipboard contents at the current location.
Public method PreviousBookmark Moves the text selection to the location of the previous bookmark in the document.
Public method ReplacePattern Replaces matching text throughout an entire text document.
Public method ReplaceText Infrastructure. Microsoft Internal Use Only.
Public method SelectAll Selects the entire document.
Public method SelectLine Selects the line containing the active point.
Public method SetBookmark Sets an unnamed bookmark on the current line in the buffer.
Public method SmartFormat Formats the selected lines of text based on the current language.
Public method StartOfDocument Moves the insertion point to the beginning of the document.
Public method StartOfLine Moves the object to the beginning of the current line.
Public method SwapAnchor Exchanges the position of the active and the anchor points.
Public method Tabify Converts spaces to tabs in the selection according to your tab settings.
Public method Unindent Removes indents from the text selection by the number of indentation levels given.
Public method Untabify Converts tabs to spaces in the selection according to the user's tab settings.
Public method WordLeft Moves the text selection left the specified number of words.
Public method WordRight Moves the text selection right the specified number of words.

Top

Remarks

The properties and methods of the TextSelection object directly reflect editor commands in the Visual Studio integrated development environment (IDE). Like the environment, text selection operations are affected by the editor's global state, such as whether it is in overwrite mode or virtual white space mode.

Any operation attempting to modify a text document fails if it affects any characters contained in a read-only block, or if the text document itself is read-only.

Some of the TextSelection object's properties and methods may fail if the associated document is an HTML document. Possible causes of the failure are: the windows that display the HTML document are not in Source view or the data behind the text document is locked.

Examples

Sub TextSelectionExample()
   ' Before running this example, open a text document.
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection
   Dim objActive As VirtualPoint = objSel.ActivePoint
   ' Collapse the selection to the beginning of the line.
   objSel.StartOfLine()
   ' objActive is "live", tied to the position of the actual selection, 
   ' so it will reflect the new position.
   Dim iCol As Long = objActive.DisplayColumn
   ' Move the selection to the end of the line.
   objSel.EndOfLine()

   MsgBox("The length of the insertion point line is " & (objActive.DisplayColumn - iCol) & " display characters.")
End Sub

See Also

Reference

EnvDTE Namespace