This document is archived and information here might be outdated. Recommended version. |
ArcObjects namespaces > Framework > ESRI.ArcGIS.Framework > Interfaces > IC > ICommandBar Interface (ArcObjects .NET 10.4 SDK) |
Provides access to members that modify a commandbar.
A CommandBar is a toolbar, menubar, menu, or context menu in the application. Use the ICommandBar interface to add commands, menus, or macro items to an existing command bar. Also use this interface to postion the command bar in the application.
Description | ||
---|---|---|
Add | Adds a new command to this commandbar. | |
Count | The number of items contained within this commandbar. | |
CreateMacroItem | Creates a new macro item on this commandbar at the specified position. | |
CreateMenu | Creates a new blank menu on this commandbar at the specified position. | |
Dock | Docks or undocks this commandbar. | |
Find | Finds a command on this commandbar. | |
IsVisible | Indicates if this commandbar is visible. | |
Item | The command item on this commandbar at the specified index. | |
Popup | Displays this commandbar as a popup menu at the specified location. |
CoClasses and Classes | Description |
---|---|
CommandBar | CommandBar object. |
Use the CommandBars collection on a Document object to get a reference to a command bar object.
Note, all programmatic customizations are temporary. If you execute VBA code to modify a commandbar or create a new menu, these changes are temporary. If you programmatically customize ArcMap, these changes will only appear while the current document is open in the current ArcMap session. Programmatic changes are never saved in the document or templates. Once you close that document or shutdown ArcMap, the changes are removed. If you are customizing ArcCatalog, these changes will only appear during the current ArcCatalog session.
The following example shows how to use the ICommandBars::Create method to create a new toolbar in Arcmap and add some items to it using the CommandBar::Add method. You would get m_app from the hook in ICommand::OnCreate().
ICommandBars commandBars=m_app.Document.CommandBars;
ICommandBar newBar=commandBars.Create("MyBar", esriCmdBarType.esriCmdBarTypeToolbar);
UID uid=new UIDClass();
uid.Value="{E1F29C6B-4E6B-11D2-AE2C-080009EC732A}";
object index=0;
newBar.Add(uid, ref index);
UID uid2=new UIDClass();
uid2.Value="{0830FB35-7EE6-11D0-87EC-080009EC732A}";
object index2=1;
newBar.Add(uid2, ref index2);
Dim commandBars As ICommandBars=m_app.Document.CommandBars
Dim newBar As ICommandBar=commandBars.Create("MyBar", esriCmdBarType.esriCmdBarTypeToolbar)
Dim uid As UID=New UIDClass()
uid.Value="{E1F29C6B-4E6B-11D2-AE2C-080009EC732A}"
Dim index As Object=0
newBar.Add(uid, index)
Dim uid2 As UID=New UIDClass()
uid2.Value="{0830FB35-7EE6-11D0-87EC-080009EC732A}"
Dim index2 As Object=1
newBar.Add(uid2, index2)