Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

TextDocument Interface

Represents a text file open in the editor, such as the Visual Studio Code editor.

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

[GuidAttribute("CB218890-1382-472B-9118-782700C88115")] 
public interface TextDocument
/** @attribute GuidAttribute("CB218890-1382-472B-9118-782700C88115") */ 
public interface TextDocument
GuidAttribute("CB218890-1382-472B-9118-782700C88115") 
public interface TextDocument

The TextDocument object is based on the Visual C++ version 6.0 Document object.

In Visual C++ version 6.0, the properties and methods of the TextDocument object were a superset of the Document object. In Visual Studio, however, Document has all the methods and properties that were part of TextDocument in Visual C++ version 6.0. In Visual Studio, TextDocument has only text-specific methods. The reason this does not break old code is that all methods that returned a TextDocument object in Visual C++ version 6.0 now return a Document object. So, old code that expects a TextDocument object actually uses a Document object.

Sub TextDocExample(ByVal dte As EnvDTE.DTE)
    Dim objTD As TextDocument = dte.ActiveDocument.Object
    MsgBox("Selection: " & objTD.Selection.Mode.ToString)
End Sub

public void TextDocExample(_DTE dte)
{
    TextDocument td = (TextDocument)dte.ActiveDocument.Object ("");
    MessageBox.Show ("Selection: " + td.Selection.Mode.ToString ());
}

Community Additions

ADD
Show:
© 2015 Microsoft