I created a static menu contains 3 static items like in this link create menus, I want to add a sub-menu and get the menu's items from database like in this image:
I already did the left part with static items, but i couldn't add the sub-menu like in the right side. I tried to do what in this link create dynamic menu, but it's not working.
EDIT: Menu code:
public sealed class TestMenu : BaseMenu, IRootLevelMenu {
public ReportingMenu() {
AddItem("Reporting.Desktop.UI.Commands.ReportSuitesCommand");// commands
AddItem("Reporting.Desktop.UI.Commands.ReportsCommand");
BeginGroup(); //Separator
AddItem("Reporting.Desktop.UI.Commands.AboutReportingCommand");
}
public override string Caption {
get {
//TODO: Replace bar caption
return "Reporting";
}
}
public override string Name {
get {
//TODO: Replace bar ID
return "ReportingMenu";
}
}
}
multi item code:
public class HowToMultiItem : IMultiItem, IMultiItemEx
{
private ESRI.ArcGIS.Controls.IHookHelper _mHookHelper;
//Step 2.
public string Caption {
get {
return "Layer Zoom";
}
}
public string Name {
get {
return "CSNETSamples_HowToMultiItem";
}
}
public int HelpContextID {
get {
return 0;
}
}
public string HelpFile {
get {
return "";
}
}
public string Message {
get {
return "MultiItem single message";
}
}
//Step 3.
public int OnPopup(object hook) {
_mHookHelper = new ESRI.ArcGIS.Controls.HookHelperClass {Hook = hook};
return _mHookHelper.FocusMap.LayerCount;
}
//Step 4.
public string get_ItemCaption(int index) {
var layer = _mHookHelper.FocusMap.Layer[index];
return "Zoom to " + layer.Name;
}
public bool get_ItemEnabled(int index) {
//Enable zoom in only when the layer is visible.
var layer = _mHookHelper.FocusMap.Layer[index];
return layer.Visible;
}
public int get_ItemBitmap(int index) {
return 0; //Not implemented.
}
public bool get_ItemChecked(int index) {
return false;
}
//Step 5.
public void OnItemClick(int index) {
//Get the layer and its spatial referenced extent.
var layer = _mHookHelper.FocusMap.Layer[index];
var env = layer.AreaOfInterest;
//Zoom to the extent and refresh the view.
var activeView = _mHookHelper.FocusMap as
ESRI.ArcGIS.Carto.IActiveView;
if (activeView == null) return;
activeView.Extent = env;
activeView.Refresh();
}
//Step 6–Optional interface implementation.
public string get_ItemMessage(int index) {
var layer = _mHookHelper.FocusMap.Layer[index];
return "Zoom to " + layer.Name + "layer.";
}
public int get_ItemHelpContextID(int index) {
return 0;
}
public string get_ItemHelpFile(int index) {
return "";
}
}