This documentation is archived and is not being maintained.

SelectedItem Property (General Extensibility)

Visual Studio .NET 2003

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

[Visual Basic .NET]
Public ReadOnly Property SelectedItem() As ToolBoxItem
[Visual Basic 6]
Property Get SelectedItem() As ToolBoxItem
[C++]
HRESULT __stdcall get_SelectedItem(
   /* [out, retval] */ ToolBoxItem** retVal
);
[C#]
public ToolBoxItem SelectedItem {get;}
[JScript .NET]
public function get SelectedItem() : ToolBoxItem

Return Value

Returns a ToolBoxItem object.

Return Value

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

Example

Sub SelectedItemExample()
   Dim objToolbox As ToolBox
   Dim colTbxTabs As ToolBoxTabs
   Dim objTab As ToolBoxTab
   Dim colTbxItems As ToolBoxItems
   Dim objTbxItem As ToolBoxItem

   ' Create an object reference to the IDE's ToolBox object.    
   objToolbox = DTE.Windows.Item(Constants.vsWindowKindToolbox).Object
   colTbxTabs = objToolbox.ToolBoxTabs

   ' Add a new tab to the ToolBox.
   objTab = colTbxTabs.Add("Sample ToolBoxTab")
   colTbxTabs = objToolbox.ToolBoxTabs

   ' Use the ToolboxItems collection to access all the items under a 
   ' ToolBoxTab.
   colTbxItems = objTab.ToolBoxItems

   ' Add a couple new ToolboxItem objects to the new tab we added above.
   objTbxItem = objTab.ToolBoxItems.Add("Text Item", "Hello world")
   objTbxItem = objTab.ToolBoxItems.Add("HTML Item", "Hello world", vsToolBoxItemFormat.vsToolBoxItemFormatHTML)

   ' List number of ToolboxItems in a ToolBoxTab.
   MsgBox("Number of items in ToolBox tab: " & colTbxItems.Count)

   ' Select the second item in the ToolboxItems collection and delete it.
   colTbxItems.Item(2).Select()
   If (MsgBox("Delete second ToolBox item?", vbYesNo) = vbYes) Then
      colTbxItems.SelectedItem.Delete()
   End If
End Sub

See Also

SelectedItem Object | SelectedItems Collection

Applies To: ToolBoxItems Collection | WizCombo Object

Show: