|
-
Jul 26th, 2002, 08:56 AM
#1
Thread Starter
Addicted Member
this sucks! I need some serious help!!!
I am writing an auction program but i have come to a screecking halt. I have a treeview list were i can ad nodes and child nodes i want to be able to save the collection of nodes to a file so that it can be opened and edited my my program users so they can keep stuff in order. but i can not save it as a treenodecollection because if throws a I/O error when it tries to save a treenodecollection object what can i do to fix this problem!!! Please Help!!! And thanks for any help you give!
also my user name use to be "B2E" but it does not work anymore and half the time i try to come to this site it does not work!
-
Jul 26th, 2002, 09:30 AM
#2
Thread Starter
Addicted Member
-
Jul 26th, 2002, 10:18 AM
#3
I'm sure there is a better way with all the serialization tricks in .net but you can always do it old school and loop through the nodes and write them to whatever you want.
-
Jul 26th, 2002, 03:06 PM
#4
Member
Here's my 2 cents on the matter. The TreenodeCollection class is not serializable, but however the System.ArrayList class is, so rather than having to loop through and save each property individually, you could just loop through and convert each node to a member of an arraylist and serialize that. There are still big problems with this, since you will need to work out a way of mapping the treenodes that will be preserved in the array, but its a start.
-
Jul 26th, 2002, 03:18 PM
#5
PowerPoster
A quick question...
when you guys are talking about making something serializable, do you mean put it into a long string?
I see a lot of that word being thrown around, and applied to everything lately, but don't understand what is being ment by it.
-
Jul 26th, 2002, 03:44 PM
#6
Member
Here is a quick example...
Dim filestream As New System.IO.FileStream("C:\temp.dat", IO.FileMode.Create)
Dim formatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
Dim temp(34) as integer
Okay, so now you have a filestream that points to the file you want to save the serialized info to, your serialization formatter and your data to be serialized. Now you just use the command
formatter.Serialize(filestream, temp)
And there you have it, "temp.dat" now contains all the data from the integer array in a binary format which can be read in much the same fashion with
temp = stuff2.Deserialize(filestream)
(provided the filestream is set to read instead of write). So for a brief explanation of serialization; its just a way of encoding classes for them to be saved or transmitted (with .net remoting).
For a class to be able to be serialized it needs to have a <Serializable> tag at the front of it when you look it up in the help file. (if you want to make your own serializable class then you will need to read about what rules apply to it). and finally the only other thing I know about serialization is that instead of using the binary formatter you can also use a soap formatter. Anyway, I'm not an expert at serialization so you should probably look it up if you want to actually use it properly, but at least now you should have some idea of what it is.
-
Jul 28th, 2002, 02:05 PM
#7
Thread Starter
Addicted Member
But?
I need to be able to get the tag from the node because i put useful(needed info in it if i put it into an array then can it be saved and work like that and me be able to retrieve the tag when i bring it back from the file.
What i really need is a code example if you would be willing to post one of how i could turn it into an array save it and then i can bring it back from the file if i can see how to save it Thanks a lot you guys have been a big help!
-
Jul 29th, 2002, 05:02 PM
#8
Thread Starter
Addicted Member
Bump
how would i loop through the treeview1 and pull out each node(including nodes which are sub nodes) and place them into a array list. I tried doing it by the index of each node, but sub nodes are classified as the same index as their parent nodes how can i get arround this and place each node into an array list
p.s. some example code would be GREAT!!
Thanks!
-
Jul 29th, 2002, 05:09 PM
#9
Thread Starter
Addicted Member
Bump
how would i loop through the treeview1 and pull out each node(including nodes which are sub nodes) and place them into a array list. I tried doing it by the index of each node, but sub nodes are classified as the same index as their parent nodes how can i get arround this and place each node into an array list
p.s. some example code would be GREAT!!
Thanks!
-
Jul 29th, 2002, 11:27 PM
#10
Thread Starter
Addicted Member
HELP(AHHHHHHHHHHHH!)
how do you serialise an arraylist and how do you deserialize it back into an array list i have tried and tried and failed each time
-
Jul 30th, 2002, 09:42 AM
#11
Lively Member
-
Jul 30th, 2002, 10:18 AM
#12
Thread Starter
Addicted Member
HOW?
xml? how whould i do that? could you explain it to me?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|