Hi anders borum,
I think you misunderstood my points.
I have two objects here ProjectNode , my business obejct and TreeNode a TreeNode of the TreeView in C#.
Whenever I add a ProjectNode to a parentNode, I am creating a TreeNode and attaching a ProjectNode Object as a tag to that one. So wherever this TreeNode is added to the TreeView, the same ProjectNode will be added as a tag.
So Now whenver I renames the TreeNode in the treview AfterSelect event, I am calling the Rename method of the Corresponding ProjectNode Business object and it first renames the Name in the ProjectNode and then fires an event which will be captured in the TreeView. So in turn, the Rename operation will be done only once in the ProjectNode. But since this Project Node is attached as a tag to a lot of TreeNodes, I am parsing through the Whole TReeView and Renaming them in the Display of the TreeView. This Rename operation is nothing to do with the DB operation which is already finished. This renaming of the all the TreeNodes in the TreeView is necessary because you need to show the changes in the ProjectNode business change graphically in the Entire TreeView.
The problem is that the entire TreeView is getting refreshed unnecessarly even if I have to rename only 5 to 6 tree nodes. Since my hierarchy treeview consists of minimum 5000 Nodes, this refreshing operation looks uglier.
Hope you understood my point here.
With Regards,
-SARADHI
"Anders Borum" <an****@sphereworks.dk> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl...
Hello!
First of all - are you persisting changes to the datastore (DB) for each and
every node? If this is the case, the wrapping all the changes in a single
Sql statement (embedded within a Sql transaction) could dramatically
increase the performance of your application.
It all depends on what you're doing .. or need to do. Iterating recursively
on a tree structure shouldn't cause a performance issue, unless we're
talking a very large amount of nodes. How many nodes are affected by a
rename operation?
In this one, I have an operation of Renaming a Project Node. So whenever
I am doing the operation of renaimg a particular Project Node, I need to rename all
the instances of the particular node in the whole Tree View.
Another thing .. you write you're updating all instances of a node in the
tree. Why is this necessary? When adding a node to the tree (i.e. adding a
project node to a parent node), you should only be adding a reference to the
node, not a copy of the node itself (causing redundance and perhaps why you
needed to introduce the event behaviour in the first place).
In this Event handler, I am searching the whole Tree view by parsing each
and every node and renaming it if it matches wiht the ProjectNode.
Definately not a good idea. Please see below .. (for instance: think of an
outside hashtable that contains your Project nodes. The tree nodes point to
these unique instances - use a hashtable if you need a single storage for
fast access of each node)
Parent Node
Project Node A (a reference that points to instance A)
Project Node A (a reference that points to instance A)
Project Node A (a reference that points to instance A)
.. instead of ..
Parent Node
Project Node A (instance data)
Project Node A (instance data)
Project Node A (instance data)
More info needed.
--
venlig hilsen / with regards
anders borum
--