Share via


CommandWindow.TextDocument 속성

창의 TextDocument 개체를 가져옵니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
ReadOnly Property TextDocument As TextDocument
TextDocument TextDocument { get; }
property TextDocument^ TextDocument {
    TextDocument^ get ();
}
abstract TextDocument : TextDocument with get
function get TextDocument () : TextDocument

속성 값

형식: EnvDTE.TextDocument
TextDocument 개체

설명

전체 문서의 영역이 읽기 전용이므로 이 속성 또는 EditPoint 개체를 사용하여 문서를 수정할 수 없습니다. 문서를 수정하려면 CommandWindow 개체의 멤버를 사용해야 합니다.

예제

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 보안

참고 항목

참조

CommandWindow 인터페이스

EnvDTE 네임스페이스

기타 리소스

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행