This documentation is archived and is not being maintained.

ToolBoxItems Collection

Visual Studio .NET 2003

Contains all items in a ToolBox tab.

DTE

   Windows

      Window

         ToolBox

            ToolBoxTabs

               ToolBoxTab

                  ToolBoxItems

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

Remarks

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

Requirements

Namespace: EnvDTE

File: dte.olb

Example

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

See Also

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

Show: