473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Treeview Control - and saving it's nodes...

Hi All,

I'm eagerly anticipating what you have to say on something that's
stumped me over the weekend. I'm writing a small application which
utilises a treeview control. I've figured out how to programatically
add nodes to it, but everytime the program is exited the treeview
control resets itself.

I looked for a save method or something similair but there doesn't seem
to be one. I have found the copyto method, and figured out how to copy
the treeview collection to an array however!

So I thought i could write this array to a file, and read it at runtime
to populate the treeview, however when I enumerate the array I only get
the parant nodes. And when I use the rank method It tells me the array
is one dimensional.

So my question is twofold really. One, am I going about this the right
way or is there a better way to save the treeview collection? And two,
how do I copy the entire treeview collection to an array, and not just
the parant nodes?

Many thanks, and in anticipation!

Gary.

Mar 27 '06 #1
1 2673
In case anyone is reading this and needs help with the treeview control
and saving it's content. I have found the answer. Firstly to get the
entire tree view, you first create an 'arraylist' and then add all the
nodes to the treeview. al in the code below is the name of an
arraylist.

foreach (TreeNode tn in tree.Nodes)
{
// add every treenode in tree.nodes to the array
al.Add(tn);
}

and how do you save this to a file? The answer is something called
serialisation, it's exactly the answer what I needed - so read up on it
if you need to save a treeview. It lets you write a complex object to a
file.

Nice when it all clicks into place!

Mar 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: serge calderara | last post by:
dear all, Is there an easy way to bind a treeview control with an XML object as datasource? In a similar way as the dataset is doing, and build columns accroding to XML node, I could imagine a...
5
by: Mark Goldin | last post by:
Anybody can shart some working samples of using that control on Windows form? Thanks
5
by: | last post by:
Is there an easy way to check the checkboxes via Code based on previously saved selection onto a database? Thanks, Victor
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
0
by: apenly | last post by:
Hi all- I'm trying to Render a TreeView in a custom control, but I'm receiving a NullReferenceException at runtime. If I put the TreeView on the page it works fine, but as soon as I try to...
1
by: doemon | last post by:
Hi, I'm working on a pagination control and I need to dynamically rerender a treeview to display the next set of nodes depending on which page we're on. For example, page 1 will dispaly only...
1
by: echuck66 | last post by:
Hi, I have a Winforms 2.0 project that I'm working on that involves populating a treeview control from data contained in a fairly large dataset that has to be refreshed periodically. I have no...
6
by: =?Utf-8?B?ZHNoZW1lc2g=?= | last post by:
Hello, I have a windows form with a TreeView control. When I first open the tree all nodes are colapsed. Then, I expand some of them and close the form. When I call Form.showDialog() once again...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.