Thanks - you are probably right - however, I am now populating the images only when a node is expanded using the OnGetImageIndex event. It has sped things up considerably.
JohnB -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rob Kennedy Sent: 25 April 2007 18:11 To: Borland's Delphi Discussion List Subject: Re: Question on TTreeView John Barrat wrote: > Is there a quicker way to set the ImageIndex for specific nodes in a > TTreeView control? > I have an application which takes 30 Seconds to load if I set the > ImageIndex on individual nodes. > > If I remove the code which sets the ImageIndex property it loads in a > less than a second. > > My code looks like this: > > procedure SetImage(iIndex: Integer; Node: TTreeNode); > begin > tLibExplorer.Items.item[Node.AbsoluteIndex].ImageIndex := iIndex; > tLibExplorer.Items.item[Node.AbsoluteIndex].SelectedIndex := iIndex; > end; The Node parameter refers to a node in the tLibExplorer tree view, right? And the Items property fetches a node from that tree view, right? So can't you just say Node.ImageIndex := iIndex; Node.SelectedIndex := iIndex; As it is now, you're asking the node where in the tree view it resides, and then asking the tree view for the node that resides at that index. But you already have that node, so skip the double lookup. The lookup is probably a linear-time operation, and since you're doing it for every node, the whole thing becomes a quadratic-time operation. -- Rob _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

