Share via


ToolBoxItems 介面

含有 [ToolBox] 索引標籤中的所有項目。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
<GuidAttribute("395C7DFB-F158-431C-8F43-DDA83B4EF54E")> _
Public Interface ToolBoxItems _
    Inherits IEnumerable
[GuidAttribute("395C7DFB-F158-431C-8F43-DDA83B4EF54E")]
public interface ToolBoxItems : IEnumerable
[GuidAttribute(L"395C7DFB-F158-431C-8F43-DDA83B4EF54E")]
public interface class ToolBoxItems : IEnumerable
[<GuidAttribute("395C7DFB-F158-431C-8F43-DDA83B4EF54E")>]
type ToolBoxItems =  
    interface
        interface IEnumerable
    end
public interface ToolBoxItems extends IEnumerable

ToolBoxItems 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 Count 取得值,表示 ToolBoxItems 集合中物件的數目。
公用屬性 DTE 取得最上層擴充性物件。
公用屬性 Parent 取得 ToolBoxItems 物件的直接上層父物件。
公用屬性 SelectedItem 取得目前在 [ToolBox] 索引標籤中選取的項目 (如果有的話)。

回頁首

方法

  名稱 說明
公用方法 Add 建立新的項目並加到 [工具箱] 中。
公用方法 GetEnumerator() 傳回會逐一查看集合的列舉程式。 (繼承自 IEnumerable)。
公用方法 GetEnumerator() 取得集合中項目的列舉值。
公用方法 Item 傳回在 ToolBoxItems 集合中的 ToolBoxItem 物件。

回頁首

備註

ToolBoxItems 集合的預設屬性是 Item,可以使用名稱或序號 (Ordinal Number) 進行索引。

範例

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

    Try
        ' 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")
        tbxTab.Activate()

        ' 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", _
        vsToolBoxItemFormat.vsToolBoxItemFormatHTML)
        tbxTabs.Item("New ToolBox Tab").ToolBoxItems.Add("DotNET _
        Component", "C:\WINNT\Microsoft.NET\Framework\v1.1.4322 _
        \System.Web.dll", vsToolBoxItemFormat. _
        vsToolBoxItemFormatDotNETComponent)

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

請參閱

參考

EnvDTE 命名空間

其他資源

HOW TO:控制工具箱