CommandWindow.Parent 屬性
取得指定物件的直接上層父物件。
命名空間: EnvDTE
組件: EnvDTE (在 EnvDTE.dll 中)
語法
'宣告
ReadOnly Property Parent As Window
Window Parent { get; }
property Window^ Parent {
Window^ get ();
}
abstract Parent : Window
function get Parent () : Window
屬性值
型別:EnvDTE.Window
Window 物件。
備註
Parent 屬性將直接上層父代傳給物件或集合。
範例
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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。