移除用 AddCommandBar 方法创建的命令栏。
命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)
语法
声明
Sub RemoveCommandBar ( _
    CommandBar As Object _
)
void RemoveCommandBar(
    Object CommandBar
)
void RemoveCommandBar(
    [InAttribute] Object^ CommandBar
)
abstract RemoveCommandBar : 
        CommandBar:Object -> unit 
function RemoveCommandBar(
    CommandBar : Object
)
参数
- CommandBar
 类型:System.Object
 必选。要移除的 CommandBar 对象。
备注
如果该命令栏是环境内部(内置)的,则此方法失败。
CommandBar 对象是 Microsoft Office 对象模型的成员。
示例
' Macro code.
Imports Microsoft.VisualStudio.CommandBars
Sub RemoveCommandBarExample()
   ' Before running, you must add a reference to the Office 
   ' typelib to gain access to the CommandBar object. Also, for this 
   ' example to work correctly, there should be an add-in available 
   ' in the Visual Studio environment.
   Dim cmds As Commands
   Dim cmdobj As Command
   Dim customin, customout As Object
   Dim cmdbarobj As CommandBar
   Dim colAddins As AddIns
   ' Set references.
   colAddins = DTE.AddIns()
   cmds = DTE.Commands
   cmdobj = cmds.Item("File.NewFile")
   ' Create a toolbar and add the File.NewFile command to it.
   cmdbarobj = cmds.AddCommandBar("Mycmdbar", _
   vsCommandBarType.vsCommandBarTypeToolbar)
   MsgBox("Commandbar name: " & cmdbarobj.Name)
   cmdobj.AddControl(cmdbarobj)
   cmds.AddNamedCommand(colAddins.Item(1), "MyCommand", _
   "Button Text", "Some tooltip", True)
   cmds.RemoveCommandBar(cmdbarobj)
End Sub
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。