andyhill Posted March 10, 2019 Share Posted March 10, 2019 I maintain an array of TreeMenu Items and create TreeMenu Nodes at runtime from this master list. Please show me how to Create Parent Node (with no children) and Parent Node with Children Node - thanks. for i:= 0 to Length(UniMainModule.MyTreeMenuItems)-1 do begin case i of // Parent (no children) 0..2: begin SystemMenu.Items.Add(UniMainModule.MyTreeMenuItems.Name); end; 3..4: begin SystemMenu.Items.Add(UniMainModule.MyTreeMenuItems.Name); end; 5..8: begin SystemMenu.Items.Add(UniMainModule.MyTreeMenuItems.Name); end; 9: begin SystemMenu.Items.Add(UniMainModule.MyTreeMenuItems.Name); end; // Parent (with children) 10: begin SystemMenu.Items.Add(UniMainModule.MyTreeMenuItems.Name); end; // Child 11..14: begin SystemMenu.Items.AddChild(10, UniMainModule.MyTreeMenuItems.Name); end; ... Link to comment Share on other sites More sharing options...
Sherzod Posted March 13, 2019 Share Posted March 13, 2019 On 3/10/2019 at 5:03 AM, andyhill said: Please show me how to Create Parent Node (with no children) and Parent Node with Children Node - thanks. Hello, procedure TMainmForm.UnimBitBtn1Click(Sender: TObject); var pNode: TUniTreeNode; begin pNode := UnimTreeMenu1.Items.Add(nil, 'Parent'); UnimTreeMenu1.Items.AddChild(pNode, 'Child') end; Link to comment Share on other sites More sharing options...
andyhill Posted March 13, 2019 Author Share Posted March 13, 2019 My code AV's at runtime, please advise - thanks. SystemMenu.BeginUpdate; SystemMenu.Items.Clear; // FAILS TO CLEAR TreeMenu !!! //SystemMenu.SourceMenu.Items.Clear; for i:= 0 to Length(UniMainModule.MyTreeMenuItems)-1 do begin // Parent Nodes if ( (i < 15) or (i = 19) or (i = 25) or (i = 32) or (i = 39) ) then begin pNode:= SystemMenu.Items.Add(nil, 'Parent'); pNode.Text:= UniMainModule.MyTreeMenuItems.Name; pNode.SelectedIndex:= i; end; // Child Nodes (uses previous pNode eg. i=14=pNode, i=15=cNode) if ( ((i > 14) and (i < 19)) or ((i > 19) and (i < 25)) or ((i > 25) and (i < 32)) or ((i > 32) and (i < 39)) ) then begin cNode:= SystemMenu.Items.AddChild(pNode, 'Child'); cNode.Text:= UniMainModule.MyTreeMenuItems.Name; cNode.SelectedIndex:= i; end; end; SystemMenu.EndUpdate; UniSession.AddJS(MainmForm.SystemMenu.JSName+'.Refresh;'); UniSession.Synchronize; Above compiles and runs but throws abstract errors. I know it may have something to do with reusing pNode and cNode objects ??? Link to comment Share on other sites More sharing options...
Sherzod Posted March 13, 2019 Share Posted March 13, 2019 Can you make a simple testcase for this? Link to comment Share on other sites More sharing options...
andyhill Posted March 14, 2019 Author Share Posted March 14, 2019 Please see Technical Support Case FSD-1166 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now