다음을 통해 공유


TextDocument Interface

Definition

Represents a text file open in the editor.

public interface class TextDocument
public interface class TextDocument
__interface TextDocument
[System.Runtime.InteropServices.Guid("CB218890-1382-472B-9118-782700C88115")]
[System.Runtime.InteropServices.TypeLibType(4160)]
public interface TextDocument
[System.Runtime.InteropServices.Guid("CB218890-1382-472B-9118-782700C88115")]
public interface TextDocument
[<System.Runtime.InteropServices.Guid("CB218890-1382-472B-9118-782700C88115")>]
[<System.Runtime.InteropServices.TypeLibType(4160)>]
type TextDocument = interface
[<System.Runtime.InteropServices.Guid("CB218890-1382-472B-9118-782700C88115")>]
type TextDocument = interface
Public Interface TextDocument
Attributes

Examples

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 ());  
}  

Remarks

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.

Properties

DTE

Gets the top-level extensibility object.

EndPoint

Gets a TextPoint object that is the location of the end of the document.

IndentSize

Microsoft Internal Use Only.

Language

Microsoft Internal Use Only.

Parent

Gets the immediate parent object of a TextDocument object.

Selection

Gets an object representing the current selection on the TextDocument object.

StartPoint

Gets the TextPoint object representing the beginning of the text document, or the first displayed character of the pane.

TabSize

Microsoft Internal Use Only.

Type

Microsoft Internal Use Only.

Methods

ClearBookmarks()

Removes all unnamed bookmarks in the text document.

CreateEditPoint(TextPoint)

Creates an EditPoint object at the specified location and returns it. The default location is the beginning of the document.

MarkText(String, Int32)

Indicates whether or not the indicated text was found in the text document and creates unnamed bookmarks wherever matching text is found.

PrintOut()

Microsoft Internal Use Only.

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.

Applies to