Share via


ToolBoxItems.SelectedItem 属性

获取**“工具箱”**选项卡中当前选定的项(如果有)。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
ReadOnly Property SelectedItem As ToolBoxItem
ToolBoxItem SelectedItem { get; }
property ToolBoxItem^ SelectedItem {
    ToolBoxItem^ get ();
}
abstract SelectedItem : ToolBoxItem with get
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 命名空间

其他资源

如何:控制工具箱