Save and Load TreeNodeCollection
Posted on 2011-09-20
I have an older Windows app (.NET 2.0) that I need to modify as minimally as possible. It contains a treeview that has several rather extensive TreeNodeCollections that load into it depending on the users choices. This takes awhile to load, because it is pulling data from the database to create the nodes.
One of the requests I have is (after the tree first loads) to save the current TreeNodeCollection to memory for later use. That way, if the user loads a different tree, and then comes back to the first, it could (in theory) load much faster because it won't have to run all the queries to the database a second time.
1) Application Starts
2) User loads Tree 1 (Tree 1 is loaded from the database)
3) User loads Tree 2 (Tree 1 is saved to memory and Tree 2 is loaded from the database)
4) User loads Tree 1 (Tree 1 is loaded from memory)
5) User loads Tree 2 (Tree 2 is loaded from memory)
I don't want to re-invent the wheel here, so has someone done this before and/or have a link to an article somewhere?