This documentation is archived and is not being maintained.

ToolBoxItems Collection

Visual Studio .NET 2003

Contains all items in a ToolBox tab.








[Visual Basic .NET]
Public Interface ToolBoxItems
    Inherits IDispatch
[Visual Basic 6]
Class ToolBoxItems
interface ToolBoxItems : IDispatch
public interface ToolBoxItems : IDispatch
[JScript .NET]
public interface ToolBoxItems extends IDispatch


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


Namespace: EnvDTE

File: dte.olb


Sub ToolBoxItemsExample()
   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.
   If (MsgBox("Delete second ToolBox item?", vbYesNo) = vbYes) Then
   End If
End Sub

See Also

Properties, Methods, and Events | ToolBox Object | ToolBoxItem Object | ToolBoxTabs Collection | ToolBoxTab Object