[SOLVED] Dynamic Menu Items bug

Answered Closed
0
0

Dynamicly building a Menu structure is causing problems..
I cannot remove menuitems by code..

If I build up the menu and do a reload of the menu I am unable to delete the MenuItems and read the ‘new’ ones.
The Old ones are still there.

So I have a fixed MenuItem “mnuMain” and a fixed MenuItem “mnuManager”, in between I want to load Menuitem dynamicly.

So without loading I have ‘ Main – Manager’.
Then I insert Employee in between.. Menu.MenuItems.Add(new MenuItem(){Text=”Employee”};

I will end up with ‘ Main – Employee -Manager’, which is what I want.

Now when I want to remove ‘Employee’ I cannot do it by code.
MainMenuBar is of type ‘MenuBar’

List<MenuItem> mRemove = new List<MenuItem>();
for (int x=0;x<MainMenuBar.MenuItems.Count;x++)
            {
                if(MainMenuBar.MenuItems[x]!=mnuMain&&MainMenuBar.MenuItems[x]!=mnuManager)
                {
                    mRemove.Add(MainMenuBar.MenuItems[x]);
                }
 
            }
            foreach(MenuItem mI in mRemove)
            {
                MainMenuBar.MenuItems.Remove(mI);
            }

 

  • You must to post comments
Best Answer
0
0

Hi Michael,

this issue is fixed in the latest build (1.3.16).

A better way to remove menu items though is to call Dispose() on them.

Best regards
Frank

  • You must to post comments
Showing 1 result