J
Jeff Gaines
I have written a file manager in C#, it uses the NET Framework as far a
possible but dives into the API/COM for those functions not provided by NET.
It uses lazy loading for the nodes of the TreeView, i.e. it only adds
child directories when a node is expanded. The 'Name' property of each
node is set to the directory path so I can use the Node.Nodes.Find
function to find a specific node.
As a consequence when I want to select a specific TreeeNode (say from
clicking a 'favourite' folder) I have to start searching at the root node,
expand each node as I find it (so the children get added) and then
continue the search, like this:
Path to display: D:\Data\Visual Studio 2008\Projects
Split the path.
Start at the root node, collapse it then expand it.
Find the node for 'D:\'
Collapse/expand it
Using the 'D:\' node as a starting point find the 'D:\Data' node etc.
It's a recursive function and it works but according to the Ants profiler
it is a bottleneck.
Can anybody think of a quicker way of getting to a specified node, bearing
in mind it may not exist at the point the search starts?
I did try keeping nodes in a hash table keyed by path but that didn't seem
to be any quicker than the Node.Nodes.Find function.
possible but dives into the API/COM for those functions not provided by NET.
It uses lazy loading for the nodes of the TreeView, i.e. it only adds
child directories when a node is expanded. The 'Name' property of each
node is set to the directory path so I can use the Node.Nodes.Find
function to find a specific node.
As a consequence when I want to select a specific TreeeNode (say from
clicking a 'favourite' folder) I have to start searching at the root node,
expand each node as I find it (so the children get added) and then
continue the search, like this:
Path to display: D:\Data\Visual Studio 2008\Projects
Split the path.
Start at the root node, collapse it then expand it.
Find the node for 'D:\'
Collapse/expand it
Using the 'D:\' node as a starting point find the 'D:\Data' node etc.
It's a recursive function and it works but according to the Ants profiler
it is a bottleneck.
Can anybody think of a quicker way of getting to a specified node, bearing
in mind it may not exist at the point the search starts?
I did try keeping nodes in a hash table keyed by path but that didn't seem
to be any quicker than the Node.Nodes.Find function.