共用方式為


SelectedItems.Parent 屬性

取得 SelectedItems 集合的直接上層父物件。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
ReadOnly Property Parent As DTE
DTE Parent { get; }
property DTE^ Parent {
    DTE^ get ();
}
abstract Parent : DTE with get
function get Parent () : DTE

屬性值

類型:EnvDTE.DTE
DTE 物件。

範例

public void CodeExample(DTE2 dte)
{  
    try
    {
        // Open project and select one or more items in 
        // Solution Explorer before running this example.
        SelectedItem selItem;
        SelectedItems selItems;
        string msg = "";
        if (dte.SelectedItems.Count > 0)
        {
            selItems = dte.SelectedItems;
            selItem = selItems.Item(1);
            msg = "The first selected item is " + selItem.Name;
            msg += "\n Do the Parent and DTE property return the same object? " + (selItems.DTE.Equals(selItems.Parent)).ToString();
        }
        MessageBox.Show(msg);
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

請參閱

參考

SelectedItems 介面

EnvDTE 命名空間

其他資源

如何:編譯和執行 Automation 物件模型程式碼範例