473,405 Members | 2,379 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,405 software developers and data experts.

Adding a TreeNodeCollection to TreeView

I have a serialized TreeNodeCollection that I want to initialize a TreeView
with. Is there a simple assignment I can use for this or do I have to
iterate thru the collection and add individual Nodes?
Nov 16 '05 #1
4 13120
Chuck Bowling wrote:
I have a serialized TreeNodeCollection that I want to initialize a TreeView
with. Is there a simple assignment I can use for this or do I have to
iterate thru the collection and add individual Nodes?


Sorry if I sound rude, but did you even try something out/checked the
documentation before asking this question? THe reason for this is that
the treeview.Nodes collection has an AddRange() method which will make
adding the collection you have a 1 liner. :)

Btw, a serialized collection, you mean a DEserialized collection, or a
serialized collection in binary format/soap format/xml?

Frans.
Nov 16 '05 #2

"Frans Bouma [C# MVP]" <pe******************@xs4all.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Chuck Bowling wrote:
I have a serialized TreeNodeCollection that I want to initialize a
TreeView with. Is there a simple assignment I can use for this or do I
have to iterate thru the collection and add individual Nodes?


Sorry if I sound rude, but did you even try something out/checked the
documentation before asking this question? THe reason for this is that the
treeview.Nodes collection has an AddRange() method which will make adding
the collection you have a 1 liner. :)

Btw, a serialized collection, you mean a DEserialized collection, or a
serialized collection in binary format/soap format/xml?


As a matter of fact, it did sound a little rude. I scoured the docs and the
internet for over an hour looking for a solution. FYI, I also tried using
AddRange before posting and couldn't get it to work. My solution didn't use
AddRange at all...
Nov 16 '05 #3
Chuck Bowling wrote:
"Frans Bouma [C# MVP]" <pe******************@xs4all.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Chuck Bowling wrote:
I have a serialized TreeNodeCollection that I want to initialize a
TreeView with. Is there a simple assignment I can use for this or do I
have to iterate thru the collection and add individual Nodes?


Sorry if I sound rude, but did you even try something out/checked the
documentation before asking this question? THe reason for this is that the
treeview.Nodes collection has an AddRange() method which will make adding
the collection you have a 1 liner. :)

Btw, a serialized collection, you mean a DEserialized collection, or a
serialized collection in binary format/soap format/xml?


As a matter of fact, it did sound a little rude. I scoured the docs and the
internet for over an hour looking for a solution. FYI, I also tried using
AddRange before posting and couldn't get it to work. My solution didn't use
AddRange at all...


You tried AddRange but it didn't work, my obvious question then is:
how didn't it work? Did you get an exception, compile error, or weren't
any nodes added?

Also, you still haven't answered what a serialized TreeNodeCollection
is :) Is that an xml file, a serialized blob from the bin formatter or a
DEserialized object?

Frans.
Nov 16 '05 #4

"Frans Bouma [C# MVP]" <pe******************@xs4all.nl> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
Chuck Bowling wrote:
"Frans Bouma [C# MVP]" <pe******************@xs4all.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Chuck Bowling wrote:
I have a serialized TreeNodeCollection that I want to initialize a
TreeView with. Is there a simple assignment I can use for this or do I
have to iterate thru the collection and add individual Nodes?

Sorry if I sound rude, but did you even try something out/checked the
documentation before asking this question? THe reason for this is that
the treeview.Nodes collection has an AddRange() method which will make
adding the collection you have a 1 liner. :)

Btw, a serialized collection, you mean a DEserialized collection, or a
serialized collection in binary format/soap format/xml?


As a matter of fact, it did sound a little rude. I scoured the docs and
the internet for over an hour looking for a solution. FYI, I also tried
using AddRange before posting and couldn't get it to work. My solution
didn't use AddRange at all...


You tried AddRange but it didn't work, my obvious question then is: how
didn't it work? Did you get an exception, compile error, or weren't any
nodes added?

Also, you still haven't answered what a serialized TreeNodeCollection is
:) Is that an xml file, a serialized blob from the bin formatter or a
DEserialized object?


If I recall, I tried to use AddRange directly as in:

TreeNodeCollection c = (TreeNodeCollection) formatter.Deserialize(stream);
treeView.AddRange(c);

or something close. Not sure now as I've moved beyond. The error is that
TreeNodeCollections are not serializable I think.

A TreeNodeCollection is a collection returned by the TreeView.Nodes
property. I solved the problem by iterating thru the TreeNodeCollection and
putting nodes in an ArrayList. That solved all the serialization problems.
Nov 16 '05 #5

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

Similar topics

0
by: | last post by:
I have derived new classes for the TreeNode and TreeView classes that Microsoft provides. Since the TreeNodeCollection class is sealed I created my own class that implements the IList interface....
4
by: Ian Powell | last post by:
Hi I've got objects in an sorted ArrayList like: P:\ P:\\DOCS P:\\i386 P:\\i386\ASMS P:\\i386\ASMS\1000 P:\\i386\ASMS\1000\MSFT
0
by: | last post by:
This is ugly, but.... If you switch the TreeView's font to a fixed-space (i.e., NOT proportional) font, such as Courier New, your original work-around of adding spaces as appropriate will work....
2
by: Chris | last post by:
Hi, anyone experience with the TreeView control that is available in the Microsoft.Web.UI.WebControls component ? I want to add a few nodes to the TreeView-control but don't know quite how :...
2
by: pmcguire67 | last post by:
There has been a lot of discussion lately about extending the treeview control to allow finding a node by key rather than by index. Everyone seems to agree that a hashtable is needed to accomplish...
12
by: Bob Hollness | last post by:
Hi. I have a text file containing a list of files and their path. I.e. c:\MyDocs\File1.txt c:\MyDocs\File2.txt c:\MyDocs\File3.txt c:\MyDocs\File4.txt C:\MyDocs\Folder\File1.txt
1
by: | last post by:
What's the best way to create new nodes on a treeview 2.0 and save them to an xml file? Thanks, Victor
2
by: Luqman | last post by:
I am using VB.Net 2005 and I want to fill the Tree View with Oracle Scott/Tiger Table which contains Parent/Child keys in one table, how can I ? In VB-6, I used TreeView Key while in VB.Net 2005,...
3
by: Bishop | last post by:
I have a treeview in my master page. It's built off a sql table that looks like this: TreeID, Name, ParentID 1,shoes,0 2,boots,0 3,slippers,0 4,shoe laces, 1 5, shoe soles, 1 6, boot laces,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.