Compartir a través de


ToolBoxItems.SelectedItem Property

Gets the item currently selected in the tab of the ToolBox, if any exist.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
ReadOnly Property SelectedItem As ToolBoxItem
ToolBoxItem SelectedItem { get; }
property ToolBoxItem^ SelectedItem {
    ToolBoxItem^ get ();
}
abstract SelectedItem : ToolBoxItem with get
function get SelectedItem () : ToolBoxItem

Property Value

Type: EnvDTE.ToolBoxItem
A ToolBoxItem object.

Remarks

If no items exist in the ToolBox tab or if no item is selected, then SelectedItem returns Nothing.

Examples

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 Security

See Also

Reference

ToolBoxItems Interface

EnvDTE Namespace

Other Resources

How to: Control the Toolbox