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 | |
---|---|---|
ActivePoint | Gets the current endpoint of the selection. | |
AnchorColumn | Infrastructure. Microsoft Internal Use Only. | |
AnchorPoint | Gets the origin point of the selection. | |
BottomLine | Infrastructure. Microsoft Internal Use Only. | |
BottomPoint | Gets the point at the end of the selection. | |
CurrentColumn | Infrastructure. Microsoft Internal Use Only. | |
CurrentLine | Infrastructure. Microsoft Internal Use Only. | |
DTE | Gets the top-level extensibility object. | |
IsActiveEndGreater | Gets whether the active point is equal to the bottom point. | |
IsEmpty | Gets whether the anchor point is equal to the active point. | |
Mode | Sets or gets a value determining whether dragging the mouse selects in stream or block mode. | |
Parent | Gets the immediate parent object of a TextSelection object. | |
Text | Sets or gets the selected text. | |
TextPane | Gets the text pane that contains the selected text. | |
TextRanges | Gets a TextRanges collection with one TextRange object for each line or partial line in the selection. | |
TopLine | Infrastructure. Microsoft Internal Use Only. | |
TopPoint | Gets the top end of the selection. |
Top
Methods
Name | Description | |
---|---|---|
Backspace | Infrastructure. Microsoft Internal Use Only. | |
Cancel | Infrastructure. Microsoft Internal Use Only. | |
ChangeCase | Changes the case of the selected text. | |
CharLeft | Moves the object the specified number of characters to the left. | |
CharRight | Moves the object the specified number of characters to the right. | |
ClearBookmark | Clears any unnamed bookmarks in the current text buffer line. | |
Collapse | Collapses the selected text to the active point. | |
Copy | Copies the selected text to the clipboard. | |
Cut | Copies the selected text to the clipboard and deletes it from its original location. | |
Delete | Deletes the selected text. | |
DeleteLeft | Deletes a specified number of characters to the left of the active point. | |
DeleteWhitespace | Deletes the empty characters (white space) horizontally or vertically around the current location in the text buffer. | |
DestructiveInsert | Inserts text, overwriting the existing text. | |
EndOfDocument | Moves the object to the end of the document. | |
EndOfLine | Moves the object to the end of the current line. | |
FindPattern | Searches for the given pattern from the active point to the end of the document. | |
FindText | Searches for the given text from the active point to the end of the document. | |
GotoLine | Moves to the beginning of the indicated line and selects the line if requested. | |
Indent | Indents the selected lines by the given number of indentation levels. | |
Insert | Inserts the given string at the current insertion point. | |
InsertFromFile | Inserts the contents of the specified file at the current location in the buffer. | |
LineDown | Moves the insertion point of the text selection down the specified number of lines. | |
LineUp | Moves the insertion point of the text selection up the specified number of lines. | |
MoveTo | Infrastructure. Microsoft Internal Use Only. | |
MoveToAbsoluteOffset | Moves the active point to the given 1-based absolute character offset. | |
MoveToDisplayColumn | Moves the active point to the indicated display column. | |
MoveToLineAndOffset | Moves the active point to the given position. | |
MoveToPoint | Moves the active point to the given position. | |
NewLine | Inserts a line break character at the active point. | |
NextBookmark | Moves to the location of the next bookmark in the document. | |
OutlineSection | Creates an outlining section based on the current selection. | |
PadToColumn | Fills the current line in the buffer with empty characters (white space) to the given column. | |
PageDown | Moves the active point a specified number of pages down in the document, scrolling the view. | |
PageUp | Moves the active point a specified number of pages up in the document, scrolling the view. | |
Paste | Inserts the clipboard contents at the current location. | |
PreviousBookmark | Moves the text selection to the location of the previous bookmark in the document. | |
ReplacePattern | Replaces matching text throughout an entire text document. | |
ReplaceText | Infrastructure. Microsoft Internal Use Only. | |
SelectAll | Selects the entire document. | |
SelectLine | Selects the line containing the active point. | |
SetBookmark | Sets an unnamed bookmark on the current line in the buffer. | |
SmartFormat | Formats the selected lines of text based on the current language. | |
StartOfDocument | Moves the insertion point to the beginning of the document. | |
StartOfLine | Moves the object to the beginning of the current line. | |
SwapAnchor | Exchanges the position of the active and the anchor points. | |
Tabify | Converts spaces to tabs in the selection according to your tab settings. | |
Unindent | Removes indents from the selected text by the number of indentation levels given. | |
Untabify | Converts tabs found at the beginning of the line to spaces according to the user's tab settings. Tabs found later in the line are not converted to spaces. | |
WordLeft | Moves the selected text left the specified number of words. | |
WordRight | Moves the selected text 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. For more information about TextSelection, see Creating and Controlling Environment Windows.
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