Freigeben über


ToolBoxItems.SelectedItem Property

Definition

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

public:
 property EnvDTE::ToolBoxItem ^ SelectedItem { EnvDTE::ToolBoxItem ^ get(); };
public:
 property EnvDTE::ToolBoxItem ^ SelectedItem { EnvDTE::ToolBoxItem ^ get(); };
[System.Runtime.InteropServices.DispId(5)]
public EnvDTE.ToolBoxItem SelectedItem { [System.Runtime.InteropServices.DispId(5)] get; }
[<System.Runtime.InteropServices.DispId(5)>]
[<get: System.Runtime.InteropServices.DispId(5)>]
member this.SelectedItem : EnvDTE.ToolBoxItem
Public ReadOnly Property SelectedItem As ToolBoxItem

Property Value

A ToolBoxItem object.

Attributes

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");  
}  

Remarks

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

Applies to