Export (0) Print
Expand All
ID
Top
Expand Minimize

Selection Property (General Extensibility)

Visual Studio .NET 2003

Returns an object representing the current selection on the object.

[Visual Basic .NET]
Public ReadOnly Property Selection() As Object
[Visual Basic 6]
Property Get Selection() As Object
[C++]
HRESULT __stdcall get_Selection(
   /* [out, retval] */ IDispatch** retVal
);
[C#]
object Selection {get;}
[JScript .NET]
public function get Selection() : Object

Remarks

For the Document object, returns the current selection in the active window associated with this document (or the topmost window of the document if none is active).

Example

Sub SelectionExample()
   ' Create a new text file.
   DTE.ItemOperations.NewFile("General\Text File")
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection
   ' Insert a line of text.
   objSel.Insert("This is a test of the emergency broadcast system.")
   ' Move to the seventh word, select it, and then output it.
   objSel.StartOfDocument()
   objSel.WordRight(False, 6)
   objSel.WordRight(True)
   MsgBox("Seventh word: " & objSel.Text)
End Sub

See Also

Text Property (General Extensibility) | TextSelection Object

Applies To: Document Object | TextDocument Object | TextPane Object | TextWindow Object | Window Object

Show:
© 2015 Microsoft