[b][red]This message was edited by sziszi81 at 2006-9-18 22:20:46[/red][/b][hr]
Hi. I have a problem with creating a menu runtime.
I have the menu structure stored in a data table MENU(ITEM, Caption, Parent)
FILENEW, &New, FILE
FILEOPEN, &Open, FILE
EDITCOPY, &Copy, EDIT
i have a procedure that creates the menu for me, but it fails creating the submenus. Since i have to find the node where i attach the submenu by it's name (the Parent field in the table) i tried to do the following:
var mi: TMenuItem;
mi:=TMenuItem.Create(mm); && mm is the TMainMenu
if Menu.FieldByName('Parent').IsNull then
(FindComponent( Menu['PARENT'] ) as TMenuItem).Add(mi);
this line fails:
[b](FindComponent( Menu['PARENT'] ) as TMenuItem).Add(mi);[/b]
What's wrong with the casting?
Or do you know a better way for this?
Thanks a lot,