.NETGURU
Treeview dynamic
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngwebcontrols' list.


=?iso-8859-1?Q?Jonathan_Hjertstr=F6m?=
Hi,

I am lost now. I really would like to make a tree view for a discussion =
forum. I can't get it to work. I want to add the nodes dynamically from =
my code behind.
I can get it down one level but I can't figure out how to append nodes =
down in the tree. Any help is greatly welcome!

I have tried looping through with this (I get my records from a Data =
Reader):

Dim xx As TreeNode =3D New TreeNode()
xx.Text =3D myDataReaderThread("Subject")
TreeView1.Nodes(i).Nodes.Add(xx)

I have seen this code that will do what I want but I can't figure out =
how to do it automatically because here the tree node is statically set.

Dim node2 As TreeNode =3D New TreeNode()
node2.Text =3D "first child"
node2.Expanded =3D True
Dim node3 As TreeNode =3D New TreeNode()
node3.Text =3D "second child"
node3.Expanded =3D True
node1.Nodes.Add(node2)
node1.Nodes.Add(node3)
Dim node4 As TreeNode =3D New TreeNode()
node4.Text =3D "first grand child"
node4.Expanded =3D True
Dim node5 As TreeNode =3D New TreeNode()
node5.Text =3D "second grand child"
node5.Expanded =3D True
node2.Nodes.Add(node4)
node3.Nodes.Add(node5)

This is how what my SQL query return:
I got the code from this site, =
http://www.sqlteam.com/item.asp?ItemID=3D1353.

PostID ThreadID ParentID PostLevel SortOrder Subject =20
1      1 1 1 1 1 Test 1 =
=20
2 1 1 2 2 2.1 Test Reply =
=20
5 1 2 3 3 3.2.1 Test =
Reply Reply
6 1 5 4 4 4.2.1 Test =
Reply Reply
4 1 1 2 5 2.2 Reply2 on =
Test 1
3 3 3 1 1 Top number 2
7 3 3 2 2 Top number 2 =
Reply

Many thanks for any tips or article.

Best regards,

**************************************************************
Jonathan Hjertstr=F6m,
Software Developer, K2-Informatics (U) Ltd.
32, Kanjokya Street, Kololo, P.O. Box 8628,
Kampala, Uganda
tel. +256 41 532 865 / 871 / 873
fax. +256 41 532 910
http://www.k2informatics.com
************************************************************** =20

Reply to this message...
 
    
Murad Kayani
Hi,

you can create treeview dynamically looping through Tree Collection =
node.

-Murad

-----Original Message-----
From: Jonathan Hjertstr=F6m [mailto:Click here to reveal e-mail address]
Sent: Tuesday, June 25, 2002 2:54 AM
To: aspngwebcontrols
Subject: [aspngwebcontrols] Treeview dynamic

Hi,

I am lost now. I really would like to make a tree view for a discussion
forum. I can't get it to work. I want to add the nodes dynamically from =
my
code behind.
I can get it down one level but I can't figure out how to append nodes =
down
in the tree. Any help is greatly welcome!

I have tried looping through with this (I get my records from a Data
Reader):

Dim xx As TreeNode =3D New TreeNode()
xx.Text =3D myDataReaderThread("Subject")
TreeView1.Nodes(i).Nodes.Add(xx)

I have seen this code that will do what I want but I can't figure out =
how to
do it automatically because here the tree node is statically set.

Dim node2 As TreeNode =3D New TreeNode()
node2.Text =3D "first child"
node2.Expanded =3D True
Dim node3 As TreeNode =3D New TreeNode()
node3.Text =3D "second child"
node3.Expanded =3D True
node1.Nodes.Add(node2)
node1.Nodes.Add(node3)
Dim node4 As TreeNode =3D New TreeNode()
node4.Text =3D "first grand child"
node4.Expanded =3D True
Dim node5 As TreeNode =3D New TreeNode()
node5.Text =3D "second grand child"
node5.Expanded =3D True
node2.Nodes.Add(node4)
node3.Nodes.Add(node5)

This is how what my SQL query return:
I got the code from this site, =
http://www.sqlteam.com/item.asp?ItemID=3D1353.

PostID ThreadID ParentID PostLevel SortOrder Subject =20
1      1 1 1 1 1 Test 1

2 1 1 2 2 2.1 Test =
Reply

5 1 2 3 3 3.2.1 Test =
Reply
Reply
6 1 5 4 4 4.2.1 Test =
Reply
Reply
4 1 1 2 5 2.2 Reply2 on =
Test
1
3 3 3 1 1 Top number 2
7 3 3 2 2 Top number 2 =
Reply

Many thanks for any tips or article.

Best regards,

**************************************************************
Jonathan Hjertstr=F6m,
Software Developer, K2-Informatics (U) Ltd.
32, Kanjokya Street, Kololo, P.O. Box 8628,
Kampala, Uganda
tel. +256 41 532 865 / 871 / 873
fax. +256 41 532 910
http://www.k2informatics.com
************************************************************** =20

| [aspngwebcontrols] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngwebcontrols.asp =3D JOIN/QUIT

Reply to this message...
 
    
devesh bhadauria
(Type your message here)

--------------------------------
From: devesh bhadauria

I am not sure how many records or node are in treeView using visual Basic
if possible then plz. send me answer

Thanks & Regards

Devesh
Reply to this message...
 
 
System.Windows.Forms.SortOrder
System.Windows.Forms.TreeNode




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification