Link to home
Start Free TrialLog in
Avatar of robotwink
robotwink

asked on

How can I dynamically create submenus?

Hello there,

I'm trying to populate a TPopupMenu at runtime. My code below only creates the main menu items. I need a loop to add more dynamic submenus for each of menus created autocratically in my code.

Please help. Thanks.
try
  ABSTableCategory.First; { Go to first record, which sets Eof False }
  while not ABSTableCategory.Eof do { Cycle until Eof is True }
var
  menuItem : TMenuItem;
 ...
  begin
    { Process each record here }
    menuItem := TMenuItem.Create(PopupMenuLeft);
    menuItem.Name := 'PopupMenuLeftSubMenuItem'+ABSTableCategory.FieldByName('categoryid').AsString;
    menuItem.Caption := ABSTableCategory.FieldByName('title').AsString;
    //menuItem.OnClick := PopupMenuRightTaheyyaClick;
 
    //assign it a custom integer value..
    menuItem.Tag := GetTickCount;
 
    PopupMenuLeft.Items.Add(menuItem);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Freddy1990
Freddy1990
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial