UID contextMenuId = new UIDClass(); Object optionalIndex = Type.Missing; contextMenuId.Value = "{3846A5B5-D3F8-44CB-BFA3-A5C30F4E535F}"; //the data view context menu ICommandBar commandBar = _mApplication.Document.CommandBars.Find(contextMenuId) as ICommandBar; contextMenuId.Value = "esriArcMapUI.ZoomInFixedCommand"; commandBar.Add(contextMenuId, ref optionalIndex);
Solved! Go to Solution.
Hi Everybody:
I ran the following code to add a command into the Data View Context Menu (the one that pops up after right clicking the map data view, as attached picture) of ArcMap. The command with the icon was added to the menu, but once I run this command after that I will get an exception.
If I do the samething manually by "Customize"==>"Customize Mode" and then drag-drop the command into the "Context Menus" in "Toolbars" tab, then the command will still work fine.
What is wrong in my code? Thank you!UID contextMenuId = new UIDClass(); Object optionalIndex = Type.Missing; contextMenuId.Value = "{3846A5B5-D3F8-44CB-BFA3-A5C30F4E535F}"; //the data view context menu ICommandBar commandBar = _mApplication.Document.CommandBars.Find(contextMenuId) as ICommandBar; contextMenuId.Value = "esriArcMapUI.ZoomInFixedCommand"; commandBar.Add(contextMenuId, ref optionalIndex);
[ATTACH=CONFIG]15415[/ATTACH]
Hi Everybody:
I ran the following code to add a command into the Data View Context Menu (the one that pops up after right clicking the map data view, as attached picture) of ArcMap. The command with the icon was added to the menu, but once I run this command after that I will get an exception.
If I do the samething manually by "Customize"==>"Customize Mode" and then drag-drop the command into the "Context Menus" in "Toolbars" tab, then the command will still work fine.
What is wrong in my code? Thank you!UID contextMenuId = new UIDClass(); Object optionalIndex = Type.Missing; contextMenuId.Value = "{3846A5B5-D3F8-44CB-BFA3-A5C30F4E535F}"; //the data view context menu ICommandBar commandBar = _mApplication.Document.CommandBars.Find(contextMenuId) as ICommandBar; contextMenuId.Value = "esriArcMapUI.ZoomInFixedCommand"; commandBar.Add(contextMenuId, ref optionalIndex);
[ATTACH=CONFIG]15415[/ATTACH]