TextDocument Interface

Represents a text file open in the editor.

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

public interface TextDocument

The TextDocument type exposes the following members.

Public propertyDTEGets the top-level extensibility object.
Public propertyEndPointGets a TextPoint object that is the location of the end of the document.
Public propertyIndentSizeInfrastructure. Microsoft Internal Use Only.
Public propertyLanguageInfrastructure. Microsoft Internal Use Only.
Public propertyParentGets the immediate parent object of a TextDocument object.
Public propertySelectionGets an object representing the current selection on the TextDocument object.
Public propertyStartPointGets the TextPoint object representing the beginning of the text document, or the first displayed character of the pane.
Public propertyTabSizeInfrastructure. Microsoft Internal Use Only.
Public propertyTypeInfrastructure. Microsoft Internal Use Only.

Public methodClearBookmarksRemoves all unnamed bookmarks in the text document.
Public methodCreateEditPointCreates an EditPoint object at the specified location and returns it. The default location is the beginning of the document.
Public methodMarkTextIndicates whether or not the indicated text was found in the text document and creates unnamed bookmarks wherever matching text is found.
Public methodPrintOutInfrastructure. Microsoft Internal Use Only.
Public methodReplacePatternReplaces matching text throughout an entire text document.
Public methodReplaceTextInfrastructure. Microsoft Internal Use Only.

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.

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

Community Additions