How can I remove a menuitem I dynamically added to a menu?
I add dynamically menu items with for example:
m:=TMenuItem.Create(nil);
m.Text:='bla bla bla';
mnuMain.AddObject(m);
I could not find ANY function to remove the entry again. I tried delete, free, removeobject etc. and the item is still nor removed and still visible. What is the trick?
I faced the same issue: TMenuItem.RemoveObject is not working and the private member FContent of TMenuView is not accessable without tricks over RTTI. That is why I build my own workaround by using a stringlist that stores the remaining menu child items before I call TMenuItem.Clear:
In case your sub menu have for each menu item an own menu handler than you have also store this event handler. In such situations a generic list of TMenuItem (TList< TMenuItem >) would be a better approach than using the string list.