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

Reply via email to