共用方式為


ToolBoxItems.SelectedItem 屬性

取得目前在 [ToolBox] 索引標籤中選取的項目 (如果有的話)。

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

語法

'宣告
ReadOnly Property SelectedItem As ToolBoxItem
    Get
ToolBoxItem SelectedItem { get; }
property ToolBoxItem^ SelectedItem {
    ToolBoxItem^ get ();
}
abstract SelectedItem : ToolBoxItem
function get SelectedItem () : ToolBoxItem

屬性值

型別:EnvDTE.ToolBoxItem
ToolBoxItem 物件。

備註

如果 [工具箱] 索引標籤上沒有項目,或者未選取項目,則 SelectedItem 會傳回 Nothing。

範例

Sub SelectedItemExample(ByVal dte As DTE2)

    ' Before running this example, select an item in the 
    ' ToolBox window.

    Dim tab As ToolBoxTab = dte.ToolWindows.ToolBox.ActiveTab
    Dim item As ToolBoxItem = tab.ToolBoxItems.SelectedItem

    If IsNothing(tab) = False Then
        MsgBox("The selected toolbox item is " & item.Name)
    Else
        MsgBox("No toolbox item is selected")
    End If

End Sub
public void SelectedItemExample(DTE2 dte)
{
    // Before running this example, select an item in the 
    // ToolBox window.

    ToolBoxTab tab = dte.ToolWindows.ToolBox.ActiveTab;
    ToolBoxItem item = tab.ToolBoxItems.SelectedItem;

    if (tab != null)
        MessageBox.Show("The selected toolbox item is " + item.Name);
    else
        MessageBox.Show("No toolbox item is selected");
}

.NET Framework 安全性

請參閱

參考

ToolBoxItems 介面

EnvDTE 命名空間

其他資源

HOW TO:控制工具箱