private void MainForm_Load(object sender, EventArgs e) { //get the MapControl and tocControl m_tocControl = (ITOCControl2)axTOCControl1.Object; m_mapControl = (IMapControl3)axMapControl1.Object; //Set buddy control for tocControl m_tocControl.SetBuddyControl(m_mapControl); axToolbarControl2.SetBuddyControl(m_mapControl); //disable the Save menu (since there is no document yet) menuSaveDoc.Enabled = false; axToolbarControl2.Select(); //Create a SchematicEditor's MenuDef object IMenuDef menuDefSchematicEditor = new CreateMenuSchematicEditor(); //Add SchematicEditor on the ToolBarMenu m_CreateMenu.AddItem(menuDefSchematicEditor, 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText); //Set the ToolbarMenu's hook m_CreateMenu.SetHook(axToolbarControl2.Object); //Set the ToolbarMenu's caption m_CreateMenu.Caption = "SchematicEditor"; /// Add ToolbarMenu on the ToolBarControl axToolbarControl2.AddItem(m_CreateMenu, -1, -1, false, 0, esriCommandStyles.esriCommandStyleMenuBar); ///Create a other ToolbarMenu for layer m_menuSchematicLayer = new ToolbarMenuClass(); m_menuLayer = new ToolbarMenuClass(); ///Add 3 items on the SchematicLayer properties menu m_menuSchematicLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicSaveEditsCommand", -1, 1, true, esriCommandStyles.esriCommandStyleIconAndText); m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicUpdateDiagramCommand", -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText); IMenuDef subMenuDef = new CreateSubMenuSchematic(); m_menuSchematicLayer.AddSubMenu(subMenuDef, 3, true); ////Add the sub-menu as the third item on the Layer properties menu, making it start a new group m_menuSchematicLayer.AddItem(new ZoomToLayer(), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly); ////Set the hook of each menu m_menuSchematicLayer.SetHook(m_mapControl); m_menuLayer.SetHook(m_mapControl); }