Share via


CommandWindow.TextDocument-Eigenschaft

Ruft TextDocument für das Fenster oder den Bereich ab.

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

Syntax

'Declaration
ReadOnly Property TextDocument As TextDocument
    Get
TextDocument TextDocument { get; }
property TextDocument^ TextDocument {
    TextDocument^ get ();
}
abstract TextDocument : TextDocument
function get TextDocument () : TextDocument

Eigenschaftswert

Typ: EnvDTE.TextDocument
Ein TextDocument-Objekt.

Hinweise

Beim Versuch, das Dokument über diese Eigenschaft oder ein EditPoint-Objekt zu ändern, tritt ein Fehler auf, da der gesamte Dokumentbereich schreibgeschützt ist. Sie können das Dokument nur durch Member im CommandWindow-Objekt ändern.

Beispiele

public void CodeExample(DTE2 dte, AddIn addin)
{
    try
    {
        // Get a reference to a Command window.
        Window win = dte.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow);
        CommandWindow cmdWin = (CommandWindow)win.Object;
        // Add some text to the window.
        cmdWin.OutputString("This is a line of text in the CommandWindow TextDocument");
        // Return the contents of the TextDocument and display them.
        TextDocument txtDoc = cmdWin.TextDocument;
        TextSelection txtSel = txtDoc.Selection;
        TextRanges txtRanges = txtSel.TextRanges;
        // Show text in textdocument.
        foreach (TextRange txtRange in txtRanges)
        {
            txtRange.StartPoint.StartOfDocument();
            MessageBox.Show(txtRange.StartPoint.GetText(txtRange.EndPoint));
        }
        // Show the CommandWindow's parent object's caption property.
        MessageBox.Show("The Parent window's caption: " + cmdWin.Parent.Caption);
        // Show the application object containing the CommandWindow.
        MessageBox.Show(cmdWin.DTE.Name);
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework-Sicherheit

Siehe auch

Referenz

CommandWindow Schnittstelle

EnvDTE-Namespace

Weitere Ressourcen

Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell