Commands.RemoveCommandBar 方法
移除以 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 物件。
備註
如果命令列是內建 (built-in) 於環境中,這個方法將會失敗。
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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。