TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
nitin 0
NA
18
0
Adding Nodes to Treeview at different levels? HELP
Dec 22 2003 9:17 AM
Hi, Its not simply adding nodes to treeview but actually what I want to do is to build a treeview on the basis of data I recieve, now the issue is that there is no fixed number of level. For example I have a table A that has say 20 Topics which has another 10 sub topics which might or might not have sub toics and so on. Now these figures will multiply as more data comes in database. what I want is that automatically all the Topics become as sibling nodes and corresponding subtopics become the child nodes and so so on. What I am using is this private void GetOracleData_Click(object sender, System.EventArgs e) { DataSet dataSet = oService.GetOracleData(); DataTable dataTable = dataSet.Tables[0]; int intIndex=0; foreach (DataRow Row in dataTable.Rows) { TreeNode tnode = new TreeNode(Row["THEMA_TITEL"].ToString()); treeView2.Nodes.Add(tnode); object intTopicId = Row["THEMA_ID"]; AddChildNodes(intIndex, intTopicId); intIndex = intIndex + 1; } } public void AddChildNodes(int intIndex, object intThemeId) { DataSet dataSet2 = oService.GetOracleThemeData(intThemeId); DataTable dataTable2 = dataSet2.Tables[0]; foreach(DataRow Row2 in dataTable2.Rows) { TreeNode tnode = new TreeNode(Row2["THEMA_TITEL"].ToString()); treeView2.Nodes[intIndex].Nodes.Add(tnode); } } But if you see here I can only go up to adding one level of child nodes but there could more child nodes for child nodes , How can I see the complete treeview structure with all parent and child nodes dynamically such that depending on the data coming the nodes are reduced or added automatically. Please help, I cannot find the answer to this anywhere, not on msdn or any forum. Awaiting your reply. Regards Nitin
Reply
Answers (
1
)
Using external files in C#...
Checkbox in Datagrid