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




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com