Hi Mark,
Thank you very much for the quick reply. I am trying to add command item to Feature Layer Context Menu in ArcMap with the below code. But I am not able to add. could you please help me what's wrong with the below code.
private void AddCommandItem()
{
IMxDocument m_MxDoc = m_application.Document as IMxDocument;
IDocument ThisDoc = m_MxDoc as IDocument;
ICommandBars CommandBars = ThisDoc.CommandBars as ICommandBars;
UID CustomCommandUID = new UID();
CustomCommandUID.Value = "ContextMenu.cmdMyItem";
object Missing = Type.Missing;
// add command to feature layer context menu
UID MenuUID = new UID();
MenuUID.Value = "esriArcMapUI.FeatureLayerContextMenu";
ICommandBar FeatureLayerContextMenu = CommandBars.Find(MenuUID.Value, false, false) as ICommandBar;
ICommandItem CustomCommandItem = FeatureLayerContextMenu.Find(CustomCommandUID, false);
if (!(CustomCommandItem != null))
FeatureLayerContextMenu.Add(CustomCommandUID, ref Missing);
// add command to raster layer context menu
MenuUID.Value = "esriArcMapUI.RasterLayerContextMenu";
ICommandBar RasterLayerContextMenu = CommandBars.Find(MenuUID, false, false) as ICommandBar;
CustomCommandItem = RasterLayerContextMenu.Find(CustomCommandUID, false);
// if not already there, add it
if (!(CustomCommandItem != null))
RasterLayerContextMenu.Add(CustomCommandUID, ref Missing);
// add command to group layer context menu
MenuUID.Value = "esriArcMapUI.GroupLayerContextMenu";
ICommandBar GroupLayerContextMenu = CommandBars.Find(MenuUID, false, false) as ICommandBar;
CustomCommandItem = GroupLayerContextMenu.Find(CustomCommandUID, false);
// if not already there, add it
if (!(CustomCommandItem != null))
GroupLayerContextMenu.Add(CustomCommandUID, ref Missing);
}
Thanks,
Uday