ToolBoxTabs.Add 方法
在 ToolBox 中建立新索引標籤,並且將它加入 ToolBoxTabs 集合。
命名空間: EnvDTE
組件: EnvDTE (在 EnvDTE.dll 中)
語法
'宣告
Function Add ( _
Name As String _
) As ToolBoxTab
ToolBoxTab Add(
string Name
)
ToolBoxTab^ Add(
[InAttribute] String^ Name
)
abstract Add :
Name:string -> ToolBoxTab
function Add(
Name : String
) : ToolBoxTab
參數
- Name
型別:System.String
必要項。索引標籤的名稱。
傳回值
型別:EnvDTE.ToolBoxTab
ToolBoxTab 物件。
範例
Sub ToolBoxAddExample()
' This adds a tab to the Toolbox.
' Define the variables and create an object reference to the IDE's
' ToolBox object.
Dim win As Window = DTE.Windows.Item(Constants.vsWindowKindToolbox)
Dim tlBox As ToolBox = win.Object
Dim tbxTabs As ToolBoxTabs
' Create an object reference to the ToolBoxTabs object.
tbxTabs = tlBox.ToolBoxTabs
' Add a new tab to the Toolbox.
tbxTabs.Add("MyTab")
End Sub
' The following example demonstrates how to add a .NET component to the
' Toolbox by using a path to the file. The component to be added must
' be a .NET control, such as a Visual Basic Windows Control Library
' component.
Sub ToolBoxItemAddExample2()
Try
Dim tlBox As ToolBox
tlBox = CType(DTE.Windows.Item(Constants. _
vsWindowKindToolbox).Object, EnvDTE.ToolBox)
' Create a new tab called "My Controls."
Dim tlBoxTab As ToolBoxTab = tlBox.ToolBoxTabs. _
Add("My Controls")
' Set focus to the new Toolbox tab.
tlBoxTab.Activate()
' Add a .NET control as a new control in the new Toolbox tab. The
' constant "vsToolBoxItemFormatDotNETComponent" alerts the Toolbox
' to the type of control you are adding.
tlBoxTab.ToolBoxItems.Add("MyDotNetControl", _
"C:\Libraries\ADotNetControl.dll(", _
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)
Catch ex As System.Exception
' Display any errors that occur.
MsgBox("ERROR: " & ex.Message)
End Try
End Sub
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。