TreeView with Recursive TreeNode....

A

Alex

Hello!
I must build a TreeView with recusive treenodes, my database as below:

id name parentID
1 name1 0
2 name2 0
3 name3 0
4 name4 1
5 name5 1
6 name6 4
7 name7 6


so my treeview looks like this:

something
name1
name4
name6
name7
name5
name2
name3


The Recursion is not known (depends on Database).
Pls help me to build it!
Thanks in advance!
 
A

Alex

Hello!
Thanks so much! but do u have another method like traditional programming? I
know nothing about XML ...:))
 
M

Mark Broadbent

Whether this data is read in as XML or not, the tree would still (IMO) have
to be built up using traditional programming methods (message calls to the
TreeView object) -so Im not too sure where Iain is coming from (although
there would be occasions that reading data from the database as XML would be
benefical).
He might be suggesting in this instance that if you have a hierachical view
of the data to recurse through then it would simplify the technique for
mirroring this in a TreeView and this is probably correct.

Anyhow whatever technique you use for reading in the data the following are
the TreeView methods you will use to build up the data tree:-


treeViewName.Nodes.Add(node) //to add a directory if tree is empty -will
only happen once
node.Nodes.Add(node) //to add a directory if parent has been found in
tree and navigated to
node.Parent //to assign a reference to a parent node of a node (for use
in navigating up the tree) -note that the reference may be null if a parent
doesnot exist
node.Nodes[x] //to assign a reference to a child node within the node's
node collection -to find is node for directory has already been added
node.Nodes.Count //for use with above

etc.etc.

It really is quite simple and you will probably be able to write some very
efficient code.
--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address will
be changed!
 
M

Mark Broadbent

please read the word "directory" as "node" in my previous post. I copied and
pasted from one of my previous posts and forgot to amend the text.

--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address will
be changed!
Mark Broadbent said:
Whether this data is read in as XML or not, the tree would still (IMO)
have to be built up using traditional programming methods (message calls
to the TreeView object) -so Im not too sure where Iain is coming from
(although there would be occasions that reading data from the database as
XML would be benefical).
He might be suggesting in this instance that if you have a hierachical
view of the data to recurse through then it would simplify the technique
for mirroring this in a TreeView and this is probably correct.

Anyhow whatever technique you use for reading in the data the following
are the TreeView methods you will use to build up the data tree:-


treeViewName.Nodes.Add(node) //to add a directory if tree is
empty -will only happen once
node.Nodes.Add(node) //to add a directory if parent has been found in
tree and navigated to
node.Parent //to assign a reference to a parent node of a node (for use
in navigating up the tree) -note that the reference may be null if a
parent doesnot exist
node.Nodes[x] //to assign a reference to a child node within the node's
node collection -to find is node for directory has already been added
node.Nodes.Count //for use with above

etc.etc.

It really is quite simple and you will probably be able to write some very
efficient code.
--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address
will be changed!
Alex said:
Hello!
Thanks so much! but do u have another method like traditional
programming? I
know nothing about XML ...:))
 
I

Iain Mcleod

Sorry. I was fresh from the pub when I wrote that. No wonder you were all
wondering what planet I was on...
<grin>

XML would not be particularly helpful in this case. I've been working a lot
with webby stuff and xslt recently and for some reason got it into my head
that he was trying to output a tree in html, forgetting I was looking at a
windoes forms forum. (Possibly the whisky consumed had something to do with
this!)

As Mark says, a function to build up the tree nodes would still have to be
written. The xml would possibly give you an advantage in already having a
tree-like structure, but not much of an advantage, esp. if you are not used
working to it (although I would take the trouble to learn it anyway at some
point as it is pretty useful for most stuff).

Sorry to confuse.

Iain (sober!)


Mark Broadbent said:
Whether this data is read in as XML or not, the tree would still (IMO)
have to be built up using traditional programming methods (message calls
to the TreeView object) -so Im not too sure where Iain is coming from
(although there would be occasions that reading data from the database as
XML would be benefical).
He might be suggesting in this instance that if you have a hierachical
view of the data to recurse through then it would simplify the technique
for mirroring this in a TreeView and this is probably correct.

Anyhow whatever technique you use for reading in the data the following
are the TreeView methods you will use to build up the data tree:-


treeViewName.Nodes.Add(node) //to add a directory if tree is
empty -will only happen once
node.Nodes.Add(node) //to add a directory if parent has been found in
tree and navigated to
node.Parent //to assign a reference to a parent node of a node (for use
in navigating up the tree) -note that the reference may be null if a
parent doesnot exist
node.Nodes[x] //to assign a reference to a child node within the node's
node collection -to find is node for directory has already been added
node.Nodes.Count //for use with above

etc.etc.

It really is quite simple and you will probably be able to write some very
efficient code.
--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address
will be changed!
Alex said:
Hello!
Thanks so much! but do u have another method like traditional
programming? I
know nothing about XML ...:))
 
A

Alex

Thank all so much!
I have successfully written by using Hashtable in a traditional programming
style.




Iain Mcleod said:
Sorry. I was fresh from the pub when I wrote that. No wonder you were all
wondering what planet I was on...
<grin>

XML would not be particularly helpful in this case. I've been working a lot
with webby stuff and xslt recently and for some reason got it into my head
that he was trying to output a tree in html, forgetting I was looking at a
windoes forms forum. (Possibly the whisky consumed had something to do with
this!)

As Mark says, a function to build up the tree nodes would still have to be
written. The xml would possibly give you an advantage in already having a
tree-like structure, but not much of an advantage, esp. if you are not used
working to it (although I would take the trouble to learn it anyway at some
point as it is pretty useful for most stuff).

Sorry to confuse.

Iain (sober!)


Mark Broadbent said:
Whether this data is read in as XML or not, the tree would still (IMO)
have to be built up using traditional programming methods (message calls
to the TreeView object) -so Im not too sure where Iain is coming from
(although there would be occasions that reading data from the database as
XML would be benefical).
He might be suggesting in this instance that if you have a hierachical
view of the data to recurse through then it would simplify the technique
for mirroring this in a TreeView and this is probably correct.

Anyhow whatever technique you use for reading in the data the following
are the TreeView methods you will use to build up the data tree:-


treeViewName.Nodes.Add(node) //to add a directory if tree is
empty -will only happen once
node.Nodes.Add(node) //to add a directory if parent has been found in
tree and navigated to
node.Parent //to assign a reference to a parent node of a node (for use
in navigating up the tree) -note that the reference may be null if a
parent doesnot exist
node.Nodes[x] //to assign a reference to a child node within the node's
node collection -to find is node for directory has already been added
node.Nodes.Count //for use with above

etc.etc.

It really is quite simple and you will probably be able to write some very
efficient code.
--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address
will be changed!
Alex said:
Hello!
Thanks so much! but do u have another method like traditional
programming? I
know nothing about XML ...:))




"Iain Mcleod" <[email protected]> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: Get it as xml.
Got SQL Server 2000? Use SQLXML.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/ht
ml/anch_SQLXML.asp


Iain


Hello!
I must build a TreeView with recusive treenodes, my database as below:

id name parentID
1 name1 0
2 name2 0
3 name3 0
4 name4 1
5 name5 1
6 name6 4
7 name7 6


so my treeview looks like this:

something
name1
name4
name6
name7
name5
name2
name3


The Recursion is not known (depends on Database).
Pls help me to build it!
Thanks in advance!
 
M

Mark Broadbent

LMAO heh heh. Listen mate what do you think you are doing going to the pub
without inviting me!

Hope the whisky was good. My favorites are the Western Isles ones (very
peaty) -e.g. Lagavullin. verynice :)
--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address will
be changed!
Iain Mcleod said:
Sorry. I was fresh from the pub when I wrote that. No wonder you were
all wondering what planet I was on...
<grin>

XML would not be particularly helpful in this case. I've been working a
lot with webby stuff and xslt recently and for some reason got it into my
head that he was trying to output a tree in html, forgetting I was looking
at a windoes forms forum. (Possibly the whisky consumed had something to
do with this!)

As Mark says, a function to build up the tree nodes would still have to
be written. The xml would possibly give you an advantage in already
having a tree-like structure, but not much of an advantage, esp. if you
are not used working to it (although I would take the trouble to learn it
anyway at some point as it is pretty useful for most stuff).

Sorry to confuse.

Iain (sober!)


Mark Broadbent said:
Whether this data is read in as XML or not, the tree would still (IMO)
have to be built up using traditional programming methods (message calls
to the TreeView object) -so Im not too sure where Iain is coming from
(although there would be occasions that reading data from the database as
XML would be benefical).
He might be suggesting in this instance that if you have a hierachical
view of the data to recurse through then it would simplify the technique
for mirroring this in a TreeView and this is probably correct.

Anyhow whatever technique you use for reading in the data the following
are the TreeView methods you will use to build up the data tree:-


treeViewName.Nodes.Add(node) //to add a directory if tree is
empty -will only happen once
node.Nodes.Add(node) //to add a directory if parent has been found in
tree and navigated to
node.Parent //to assign a reference to a parent node of a node (for
use in navigating up the tree) -note that the reference may be null if a
parent doesnot exist
node.Nodes[x] //to assign a reference to a child node within the
node's node collection -to find is node for directory has already been
added
node.Nodes.Count //for use with above

etc.etc.

It really is quite simple and you will probably be able to write some
very
efficient code.
--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address
will be changed!
Alex said:
Hello!
Thanks so much! but do u have another method like traditional
programming? I
know nothing about XML ...:))




"Iain Mcleod" <[email protected]> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: Get it as xml.
Got SQL Server 2000? Use SQLXML.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/ht
ml/anch_SQLXML.asp


Iain


Hello!
I must build a TreeView with recusive treenodes, my database as
below:

id name parentID
1 name1 0
2 name2 0
3 name3 0
4 name4 1
5 name5 1
6 name6 4
7 name7 6


so my treeview looks like this:

something
name1
name4
name6
name7
name5
name2
name3


The Recursion is not known (depends on Database).
Pls help me to build it!
Thanks in advance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top