ToolBoxItems Interface

Contains all items in a ToolBox tab.

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

public interface ToolBoxItems : IEnumerable

The ToolBoxItems type exposes the following members.

Public propertyCountGets a value indicating the number of objects in the ToolBoxItems collection.
Public propertyDTEGets the top-level extensibility object.
Public propertyParentGets the immediate parent object of a ToolBoxItems object.
Public propertySelectedItemGets the item currently selected in the tab of the ToolBox, if any exist.

Public methodAddCreates a new item and adds it to the ToolBox.
Public methodGetEnumeratorGets an enumerator for items in the collection.
Public methodItemReturns a ToolBoxItem object in a ToolBoxItems collection.

The default property of the ToolBoxItems collection is Item, which can be indexed either by name or by ordinal number.

Sub ToolBoxItemsExample()
    Dim tlBox As ToolBox
    Dim tbxTabs As ToolBoxTabs
    Dim tbxTab As ToolBoxTab
    Dim tbxItems As ToolBoxItems

        ' Create an object reference to the IDE's ToolBox object and
        ' its tabs.
        tlBox = DTE.Windows.Item(Constants.vsWindowKindToolbox).Object
        tbxTabs = tlBox.ToolBoxTabs

        ' Add a new tab to the ToolBox and select it.
        tbxTab = tbxTabs.Add("New ToolBox Tab")

        ' Add new items to the new ToolBox tab. This shows two
        ' different ways to index the ToolBox tabs. The third item
        ' added is a .NET component that contains a number of 
        ' Web-related controls.
        tbxTab.ToolBoxItems.Add("Text Item", "Hello world")
        tbxTab.ToolBoxItems.Add("HTML Item", "Hello world", _
        tbxTabs.Item("New ToolBox Tab").ToolBoxItems.Add("DotNET _
        Component", "C:\WINNT\Microsoft.NET\Framework\v1.1.4322 _
        \System.Web.dll", vsToolBoxItemFormat. _

        ' Use the ToolboxItems collection to access all the items under 
        ' a ToolBox tab.
        tbxItems = tbxTab.ToolBoxItems

        ' List number of ToolboxItems in a ToolBoxTab.
        MsgBox("Number of items in " & tbxTabs.Item(1).Name & " tab: _
        " & tbxItems.Count)

        ' Select the second item in the ToolboxItems collection and 
        ' delete it.
        If (MsgBox("Delete second ToolBox item?", vbYesNo) = vbYes) _
            MsgBox("Number of items in " & tbxTabs.Item(1).Name & " _
            tab: " & tbxItems.Count)
        End If
    Catch ex As System.Exception
        MsgBox("ERROR: " & ex.Message)
    End Try
End Sub