RobYost Posted November 9, 2017 Share Posted November 9, 2017 if I add code to the form show I am able to add subItems procedure TMainmForm.UnimFormShow(Sender: TObject); var n1, n2, n3: TUniTreeNode; begin n1 := nl1.Items.Add(nil, '11111'); n2 := nl1.Items.Add(nil, '22222'); n3 := nl1.Items.Add(nil, '33333'); nl1.Items.Add(n1, 'aaaa'); nl1.Items.Add(n2, 'bbbb'); nl1.Items.Add(n3, 'cccc'); end; Clicking on 1 goes to a; 2 goes to b etc. but if I put the very same code in a button procedure TMainmForm.btn1Click(Sender: TObject); var n1, n2, n3: TUniTreeNode; begin n1 := nl1.Items.Add(nil, '11111'); n2 := nl1.Items.Add(nil, '22222'); n3 := nl1.Items.Add(nil, '33333'); nl1.Items.Add(n1, 'aaaa'); nl1.Items.Add(n2, 'bbbb'); nl1.Items.Add(n3, 'cccc'); end; clicking on 1 goes to a, but clicking on 2 and 3 trigger OnLeafClick and have no subitems Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 9, 2017 Share Posted November 9, 2017 Hi, Which build are you using ?! I couldn't reproduce this issue. But you can try to use BeginUpdate, EndUpdate methods: var n1, n2, n3: TUniTreeNode; begin nl1.BeginUpdate; n1 := nl1.Items.Add(nil, '11111'); n2 := nl1.Items.Add(nil, '22222'); n3 := nl1.Items.Add(nil, '33333'); nl1.Items.Add(n1, 'aaaa'); nl1.Items.Add(n2, 'bbbb'); nl1.Items.Add(n3, 'cccc'); nl1.EndUpdate; end; Best regards, Quote Link to comment Share on other sites More sharing options...
RobYost Posted November 9, 2017 Author Share Posted November 9, 2017 I have attached the whole test project but this is the main code. unit Mainm; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUImClasses, uniGUIRegClasses, uniGUIForm, uniGUImForm, uniGUImJSForm, uniGUIBaseClasses, uniTreeView, unimNestedList, uniButton, unimButton; type TMainmForm = class(TUnimForm) nl1: TUnimNestedList; btn1: TUnimButton; procedure btn1Click(Sender: TObject); procedure UnimFormShow(Sender: TObject); procedure nl1LeafClick(Sender: TObject); private public { Public declarations } end; function MainmForm: TMainmForm; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication; function MainmForm: TMainmForm; begin Result := TMainmForm(UniMainModule.GetFormInstance(TMainmForm)); end; procedure TMainmForm.nl1LeafClick(Sender: TObject); begin MessageDlg('Leaf Clicked', mtInformation, [mbOK]); end; procedure addItems(nl: TUnimNestedList); var n1, n2, n3: TUniTreeNode; begin n1 := nl.Items.Add(nil, '11111'); n2 := nl.Items.Add(nil, '22222'); n3 := nl.Items.Add(nil, '33333'); nl.Items.Add(n1, 'aaaa'); nl.Items.Add(n2, 'bbbb'); nl.Items.Add(n3, 'cccc'); end; procedure TMainmForm.btn1Click(Sender: TObject); begin; // only the first item of the list when clicked goes to its subitem. addItems(nl1); end; procedure TMainmForm.UnimFormShow(Sender: TObject); begin // Uncomment below and you will see it works correctly // addItems(nl1); end; initialization RegisterAppFormClass(TMainmForm); end. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 9, 2017 Share Posted November 9, 2017 But you can try to use BeginUpdate, EndUpdate methods: var n1, n2, n3: TUniTreeNode; begin nl1.BeginUpdate; n1 := nl1.Items.Add(nil, '11111'); n2 := nl1.Items.Add(nil, '22222'); n3 := nl1.Items.Add(nil, '33333'); nl1.Items.Add(n1, 'aaaa'); nl1.Items.Add(n2, 'bbbb'); nl1.Items.Add(n3, 'cccc'); nl1.EndUpdate; end; Quote Link to comment Share on other sites More sharing options...
RobYost Posted November 9, 2017 Author Share Posted November 9, 2017 I tried that, but it made no difference. But you can try to use BeginUpdate, EndUpdate methods: var n1, n2, n3: TUniTreeNode; begin nl1.BeginUpdate; n1 := nl1.Items.Add(nil, '11111'); n2 := nl1.Items.Add(nil, '22222'); n3 := nl1.Items.Add(nil, '33333'); nl1.Items.Add(n1, 'aaaa'); nl1.Items.Add(n2, 'bbbb'); nl1.Items.Add(n3, 'cccc'); nl1.EndUpdate; end; Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted November 9, 2017 Administrators Share Posted November 9, 2017 Dynamic addition of items to NestedList is not fully implemented yet. Sent from my SM-N900 using Tapatalk Quote Link to comment Share on other sites More sharing options...
RobYost Posted November 9, 2017 Author Share Posted November 9, 2017 OK. I will implement this some other way 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.