CommandWindow.TextDocument 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 TextDocument 窗口或窗格的。
public:
property EnvDTE::TextDocument ^ TextDocument { EnvDTE::TextDocument ^ get(); };
public:
property EnvDTE::TextDocument ^ TextDocument { EnvDTE::TextDocument ^ get(); };
[System.Runtime.InteropServices.DispId(6)]
public EnvDTE.TextDocument TextDocument { [System.Runtime.InteropServices.DispId(6)] get; }
[<System.Runtime.InteropServices.DispId(6)>]
[<get: System.Runtime.InteropServices.DispId(6)>]
member this.TextDocument : EnvDTE.TextDocument
Public ReadOnly Property TextDocument As TextDocument
属性值
TextDocument 对象。
- 属性
示例
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);
}
}
注解
尝试通过此属性或对象修改文档将 EditPoint 会失败,因为整个文档的区域是只读的。 仅可通过对象中的成员修改文档 CommandWindow 。