delphi - TMainMenu build menu item dynamic -


on system , main menu dynamic, builded data in database.

i have specific situation menu items need assembled before being displayed.

let's assume menu has following main items:

files - customer - reports - about

when click in reports menu item must assemble items before displayed.

i did analysis of code in tmainmenu, tmenu , tmenuitem class. unfortunately have not found simple solution problem.

exist way create these items before being displayed?

there trick can use. need add 1 dummy tmenuitem under reports , set visible property false. add onclick event reports item , populating logic there. before add new items have delete existing ones, should leave dummy item intact.

something like:

procedure tform1.reportitemclick(sender: tobject); var   item: tmenuitem;   i: integer; begin   // delete items first - dummy - 1   := reportitem.count - 1 downto 1     reportitem.items[i].free;    item := tmenuitem.create(reportitem);   item.caption := 'abc'; //  item.onclick := ... //  or //  item.action := ...   reportitem.add(item);    item := tmenuitem.create(reportitem);   item.caption := '123'; //  item.onclick := ... //  or //  item.action := ...   reportitem.add(item); end; 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -