Board index » delphi » Slooooooowww TTreeview...

Slooooooowww TTreeview...

Hello,

I have the following code to dynamically create a TTreeView when a form
is created:

(TableList is a TstringList and FieldList is an array of StringLists.)

procedure TDataForm.LoadFields;

Var I,j : longint;
    cnode,dnode : TTreeNode;
    S : String;

begin
  FieldsTreeView.Items.Clear;
  FieldsTreeView.SortType:=stnone;
  If Assigned(FPackage) Then
    With FieldsTreeView.Items do
      for i:=FPackage.TableList.Count-1 downto 1 do
        begin
        S:=FPackage.TableList[i];
        Cnode:=AddChild(Nil,S);
        cnode.imageindex:=1;
        cnode.selectedindex:=1;
        for J:=FPackage.FieldList[i].Count-1 downto 0 do
          begin
          S:=FPackage.FieldList[i].Strings[j];
          dnode:=AddChild(CNode,S);
          dnode.imageindex:=0;
          end;
        end;
end;

(In total about 2200 nodes are created)

This code used to fill the tree almost instantly in when compiled with
Delphi 4.
Compiled with Delphi 5 it takes up to 1 minute before the treeview is
filled !
(tests done on a PII 350 Mhz, running Windows NT)

I can speed up the building of the tree by making sure that the
stringlists are
sorted, and using AddChildFirst instead of AddChild; then the loading
still takes 15
seconds.

This is unacceptable behaviour for the users of our program; Is there
any reason
why this code has become so slow in Delphi 5 ? HAs anything changed in
the TTreeView ?

Michael.

 

Re:Slooooooowww TTreeview...


I hope you find out, I have had to simplify my TreeView until I can find an
answer.

Regards,
Clif Collins

Re:Slooooooowww TTreeview...


Is there not a beginupdate/endupdate for the tree?

Michael Van Canneyt <Michael.VanCann...@wisa.be> wrote in message
news:383D4820.47FB069D@wisa.be...

Quote
> Hello,

> I have the following code to dynamically create a TTreeView when a form
> is created:

> (TableList is a TstringList and FieldList is an array of StringLists.)

> procedure TDataForm.LoadFields;

> Var I,j : longint;
>     cnode,dnode : TTreeNode;
>     S : String;

> begin
>   FieldsTreeView.Items.Clear;
>   FieldsTreeView.SortType:=stnone;
>   If Assigned(FPackage) Then
>     With FieldsTreeView.Items do
>       for i:=FPackage.TableList.Count-1 downto 1 do
>         begin
>         S:=FPackage.TableList[i];
>         Cnode:=AddChild(Nil,S);
>         cnode.imageindex:=1;
>         cnode.selectedindex:=1;
>         for J:=FPackage.FieldList[i].Count-1 downto 0 do
>           begin
>           S:=FPackage.FieldList[i].Strings[j];
>           dnode:=AddChild(CNode,S);
>           dnode.imageindex:=0;
>           end;
>         end;
> end;

> (In total about 2200 nodes are created)

> This code used to fill the tree almost instantly in when compiled with
> Delphi 4.
> Compiled with Delphi 5 it takes up to 1 minute before the treeview is
> filled !
> (tests done on a PII 350 Mhz, running Windows NT)

> I can speed up the building of the tree by making sure that the
> stringlists are
> sorted, and using AddChildFirst instead of AddChild; then the loading
> still takes 15
> seconds.

> This is unacceptable behaviour for the users of our program; Is there
> any reason
> why this code has become so slow in Delphi 5 ? HAs anything changed in
> the TTreeView ?

> Michael.

Re:Slooooooowww TTreeview...


have to tried inserting the BeginUpdate and EndUpdate procedures?

Michael Van Canneyt <Michael.VanCann...@wisa.be> wrote in message
news:383D4820.47FB069D@wisa.be...

Quote
> Hello,

> I have the following code to dynamically create a TTreeView when a form
> is created:

> (TableList is a TstringList and FieldList is an array of StringLists.)

> procedure TDataForm.LoadFields;

> Var I,j : longint;
>     cnode,dnode : TTreeNode;
>     S : String;

> begin
>   FieldsTreeView.Items.Clear;
>   FieldsTreeView.SortType:=stnone;
>   If Assigned(FPackage) Then
>     With FieldsTreeView.Items do
>       for i:=FPackage.TableList.Count-1 downto 1 do
>         begin
>         S:=FPackage.TableList[i];
>         Cnode:=AddChild(Nil,S);
>         cnode.imageindex:=1;
>         cnode.selectedindex:=1;
>         for J:=FPackage.FieldList[i].Count-1 downto 0 do
>           begin
>           S:=FPackage.FieldList[i].Strings[j];
>           dnode:=AddChild(CNode,S);
>           dnode.imageindex:=0;
>           end;
>         end;
> end;

> (In total about 2200 nodes are created)

> This code used to fill the tree almost instantly in when compiled with
> Delphi 4.
> Compiled with Delphi 5 it takes up to 1 minute before the treeview is
> filled !
> (tests done on a PII 350 Mhz, running Windows NT)

> I can speed up the building of the tree by making sure that the
> stringlists are
> sorted, and using AddChildFirst instead of AddChild; then the loading
> still takes 15
> seconds.

> This is unacceptable behaviour for the users of our program; Is there
> any reason
> why this code has become so slow in Delphi 5 ? HAs anything changed in
> the TTreeView ?

> Michael.

Re:Slooooooowww TTreeview...


You can try for these purposes RapidTree or FlyTreeView RapidEdition - 100%
Delphi VCL, fastest tree in the world (add 20000 nodes ~0.5sec).
For more info Please visit http://www.imcasys.com

Keith Chew SL <keith...@ihug.co.nz> wrote in message
news:81k7ae$oi8$1@newsource.ihug.co.nz...

Quote
> have to tried inserting the BeginUpdate and EndUpdate procedures?

> Michael Van Canneyt <Michael.VanCann...@wisa.be> wrote in message
> news:383D4820.47FB069D@wisa.be...
> > Hello,

> > I have the following code to dynamically create a TTreeView when a form
> > is created:

> > (TableList is a TstringList and FieldList is an array of StringLists.)

> > procedure TDataForm.LoadFields;

> > Var I,j : longint;
> >     cnode,dnode : TTreeNode;
> >     S : String;

> > begin
> >   FieldsTreeView.Items.Clear;
> >   FieldsTreeView.SortType:=stnone;
> >   If Assigned(FPackage) Then
> >     With FieldsTreeView.Items do
> >       for i:=FPackage.TableList.Count-1 downto 1 do
> >         begin
> >         S:=FPackage.TableList[i];
> >         Cnode:=AddChild(Nil,S);
> >         cnode.imageindex:=1;
> >         cnode.selectedindex:=1;
> >         for J:=FPackage.FieldList[i].Count-1 downto 0 do
> >           begin
> >           S:=FPackage.FieldList[i].Strings[j];
> >           dnode:=AddChild(CNode,S);
> >           dnode.imageindex:=0;
> >           end;
> >         end;
> > end;

> > (In total about 2200 nodes are created)

> > This code used to fill the tree almost instantly in when compiled with
> > Delphi 4.
> > Compiled with Delphi 5 it takes up to 1 minute before the treeview is
> > filled !
> > (tests done on a PII 350 Mhz, running Windows NT)

> > I can speed up the building of the tree by making sure that the
> > stringlists are
> > sorted, and using AddChildFirst instead of AddChild; then the loading
> > still takes 15
> > seconds.

> > This is unacceptable behaviour for the users of our program; Is there
> > any reason
> > why this code has become so slow in Delphi 5 ? HAs anything changed in
> > the TTreeView ?

> > Michael.

Other Threads