Export (0) Print
Expand All

OutputWindowPane.TextDocument Property

Gets the TextDocument object for the OutputWindowPane .

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

TextDocument TextDocument { get; }
/** @property */
TextDocument get_TextDocument ()

function get TextDocument () : TextDocument

Property Value

A TextDocument object.

Attempting to modify the document through this property or an EditPoint fails because the entire document's region is read-only. You can modify the document only through members on CommandWindow.

public void TextDocumentExample(DTE2 dte)
{
    // Retrieve and show the Output window.
    OutputWindow outWin = dte.ToolWindows.OutputWindow;
    outWin.Parent.AutoHides = false;
    outWin.Parent.Activate();

    // Find the "Pane1" Output window pane; if it does not exist, 
    // create it.
    OutputWindowPane pane1 = null;
    try
    {
        pane1 = outWin.OutputWindowPanes.Item("Pane1");
    }
    catch
    {
        pane1 = outWin.OutputWindowPanes.Add("Pane1");
    }
    finally
    {
        pane1.Clear();
    }

    // Write 10 lines of text to Pane1.
    for (int i = 1; i <= 10; i++)
        pane1.OutputString("Line " + i.ToString() + "\n");

    // Retrieve the text from Pane1.
    TextDocument doc = pane1.TextDocument;
    TextSelection sel = doc.Selection;

    sel.StartOfDocument(false);
    sel.EndOfDocument(true);

    MessageBox.Show("Text in Pane1:\n\n" + sel.Text);
}

Community Additions

ADD
Show:
© 2014 Microsoft