Condividi tramite


TextSelection Interface

Definition

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

public interface class TextSelection
public interface class TextSelection
__interface TextSelection
[System.Runtime.InteropServices.Guid("1FA0E135-399A-4D2C-A4FE-D21E2480F921")]
[System.Runtime.InteropServices.TypeLibType(4160)]
public interface TextSelection
[System.Runtime.InteropServices.Guid("1FA0E135-399A-4D2C-A4FE-D21E2480F921")]
public interface TextSelection
[<System.Runtime.InteropServices.Guid("1FA0E135-399A-4D2C-A4FE-D21E2480F921")>]
[<System.Runtime.InteropServices.TypeLibType(4160)>]
type TextSelection = interface
[<System.Runtime.InteropServices.Guid("1FA0E135-399A-4D2C-A4FE-D21E2480F921")>]
type TextSelection = interface
Public Interface TextSelection
Attributes

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  

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.

Properties

ActivePoint

Gets the current endpoint of the selection.

AnchorColumn

Microsoft Internal Use Only.

AnchorPoint

Gets the origin point of the selection.

BottomLine

Microsoft Internal Use Only.

BottomPoint

Gets the point at the end of the selection.

CurrentColumn

Microsoft Internal Use Only.

CurrentLine

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 text selection.

TextPane

Gets the text pane that contains the text selection.

TextRanges

Gets a TextRanges collection with one TextRange object for each line or partial line in the selection.

TopLine

Microsoft Internal Use Only.

TopPoint

Gets the top end of the selection.

Methods

Backspace(Int32)

Microsoft Internal Use Only.

Cancel()

Microsoft Internal Use Only.

ChangeCase(vsCaseOptions)

Changes the case of the text selection.

CharLeft(Boolean, Int32)

Moves the object the specified number of characters to the left.

CharRight(Boolean, Int32)

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 text selection to the active point.

Copy()

Copies the text selection to the clipboard.

Cut()

Copies the text selection to the clipboard and deletes it from its original location.

Delete(Int32)

Deletes the text selection.

DeleteLeft(Int32)

Deletes a specified number of characters to the left of the active point.

DeleteWhitespace(vsWhitespaceOptions)

Deletes the empty characters (white space) horizontally or vertically around the current location in the text buffer.

DestructiveInsert(String)

Inserts text, overwriting the existing text.

EndOfDocument(Boolean)

Moves the object to the end of the document.

EndOfLine(Boolean)

Moves the object to the end of the current line.

FindPattern(String, Int32, TextRanges)

Searches for the given pattern from the active point to the end of the document. This API has been deprecated in VS 2022 and above. Please refer the breaking API changes in VS 2022 for guidance on how to migrate API usage via modern find and repalce APIs.

FindText(String, Int32)

Searches for the given text from the active point to the end of the document. This API has been deprecated in VS 2022 and above. Please refer the breaking API changes in VS 2022 for guidance on how to migrate API usage via modern find and repalce APIs.

GotoLine(Int32, Boolean)

Moves to the beginning of the indicated line and selects the line if requested.

Indent(Int32)

Indents the selected lines by the given number of indentation levels.

Insert(String, Int32)

Inserts the given string at the current insertion point.

InsertFromFile(String)

Inserts the contents of the specified file at the current location in the buffer.

LineDown(Boolean, Int32)

Moves the insertion point of the text selection down the specified number of lines.

LineUp(Boolean, Int32)

Moves the insertion point of the text selection up the specified number of lines.

MoveTo(Int32, Int32, Boolean)

Microsoft Internal Use Only.

MoveToAbsoluteOffset(Int32, Boolean)

Moves the active point to the given 1-based absolute character offset.

MoveToDisplayColumn(Int32, Int32, Boolean)

Moves the active point to the indicated display column.

MoveToLineAndOffset(Int32, Int32, Boolean)

Moves the active point to the given position.

MoveToPoint(TextPoint, Boolean)

Moves the active point to the given position.

NewLine(Int32)

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(Int32)

Fills the current line in the buffer with empty characters (white space) to the given column.

PageDown(Boolean, Int32)

Moves the active point a specified number of pages down in the document, scrolling the view.

PageUp(Boolean, Int32)

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(String, String, Int32, TextRanges)

Replaces matching text throughout an entire text document. This API has been deprecated in VS 2022 and above. Please refer the breaking API changes in VS 2022 for guidance on how to migrate API usage via modern find and repalce APIs.

ReplaceText(String, String, Int32)

Microsoft Internal Use Only. This API has been deprecated in VS 2022 and above. Please refer the breaking API changes in VS 2022 for guidance on how to migrate API usage via modern find and repalce APIs.

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(Boolean)

Moves the insertion point to the beginning of the document.

StartOfLine(vsStartOfLineOptions, Boolean)

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(Int32)

Removes indents from the text selection by the number of indentation levels given.

Untabify()

Converts tabs to spaces in the selection according to the user's tab settings.

WordLeft(Boolean, Int32)

Moves the text selection left the specified number of words.

WordRight(Boolean, Int32)

Moves the text selection right the specified number of words.

Applies to