Luciano França Posted May 22, 2023 Share Posted May 22, 2023 Attached my example that I can't show the images or set the onClick event Procedure P_CopyMenuToTreeView(aMenu: TUniMenuItem; aTreeview: TUniTreeMenu); Procedure AddItems(anItem: TUniMenuItem; aParentNode: TUniTreeNode); Var node: TUniTreeNode; I: Integer; Begin For I := 0 To anItem.Count - 1 Do Begin node := aTreeview.Items.AddChild(aParentNode, anItem.Items[I].Caption); node.ImageIndex := anItem.Items[I].ImageIndex; // Because it does not work node.OnClick := anItem.Items[I].OnClick; AddItems(anItem.Items[I], node); End; End; Begin aTreeview.Items.Clear; If Assigned(aMenu) Then AddItems(aMenu, nil); End; ImageList TreeList.7z Quote Link to comment Share on other sites More sharing options...
Luciano França Posted May 22, 2023 Author Share Posted May 22, 2023 From what I saw in old posts, "TUniTreeMenu" does not support BMP or PNG, is this limitation still in force in 2023? Will I have to use fonts with icons ? About the event node.OnClick := anItem.Items[I].OnClick; Solution procedure TForm_BuscaMainMenuHost.UniDBTreeListClick(Sender: TObject); Var I : Integer; Var fText: String; begin if not Assigned(DBTreeList.Selected) Then Exit; fText := DBTreeList.Selected.Text; if trim(fText) <> EmptyStr Then For I := 0 to Form_MenuPrincipal.ComponentCount - 1 do if Form_MenuPrincipal.Components[I] is TMenuItem then Begin if Trim((Form_MenuPrincipal.Components[I] as TMenuItem).Caption) = Trim(fText) Then Begin vBuscarMenu := false; (Form_MenuPrincipal.Components[I] as TMenuItem).OnClick((Form_MenuPrincipal.Components[I] as TMenuItem)); vBuscarMenu := True; Break; End; End; end; But I don't understand why it doesn't work node.OnClick := anItem.Items[I].OnClick; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.