|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Treeview problemin hierarchical way. Database structure is: ID, FirstName, LastName, IDBoss - IDBoss is referenced to ID. Treeview should look like this: -employee1 ---employee2 ---employee3 ------employee4 ---employee5 ---employee6 ------employee7 ---------employee8 ------employee9 Can someone please send here some code (please in vb.net 2005) that will do that work, or give me a hint. So far I create function that populate treeview but only 3 levels. Here is my code: (Sorry on my english) ---- Private Sub FillTree() Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\baza.mdb") Dim rootAdapter As New OleDb.OleDbDataAdapter("SELECT * FROM zaposlenici WHERE ID = 1", conn) Dim childAdapter As New OleDb.OleDbDataAdapter("SELECT * FROM zaposlenici WHERE ID <> 1", conn) Dim treeDataSet As New DataSet() treeDataSet.EnforceConstraints = False rootAdapter.Fill(treeDataSet, "Parents") childAdapter.Fill(treeDataSet, "Children") treeDataSet.Relations.Add("relacija", treeDataSet.Tables("Parents").Columns("ID"), _ treeDataSet.Tables("Children").Columns("IDBoss")) treeDataSet.Relations.Add("relacija2", _ treeDataSet.Tables("Children").Columns("ID"), _ treeDataSet.Tables("Children").Columns("IDBoss")) TreeView1.Nodes.Clear() Dim parent As DataRow For Each parent In treeDataSet.Tables("Parents").Rows Dim parentNode As New TreeNode(parent("LastName").ToString() & " " & parent("FirstName").ToString()) Dim child As DataRow For Each child In parent.GetChildRows("relacija") Dim folderNode As New TreeNode(child("LastName").ToString() & " " & child("FirstName").ToString()) Dim item As DataRow For Each item In child.GetChildRows("relacija2") folderNode.Nodes.Add(New TreeNode(item("LastName").ToString() & " " & item("FirstName").ToString())) Next item parentNode.Nodes.Add(folderNode) Next child TreeView1.Nodes.Add(parentNode) Next parent TreeView1.ExpandAll() End Sub I would solve this by:
Filling a dataset with all employees. Using RECURSION I would add an employee, and then iterate through the dataset to find any one below him. Rinse, lather, and repeat. "Steven Nagy" <learndot***@hotmail.com> wrote in message can you write some example code, please.news:1152762448.574278.33900@p79g2000cwp.googlegroups.com... >I would solve this by: > > Filling a dataset with all employees. > Using RECURSION I would add an employee, and then iterate through the > dataset to find any one below him. > > Rinse, lather, and repeat. >
Validating textbox w/ Cancel button
sql server 2005 tools configuration starts when I build a distribution project (VB 2005) Delegate et al Mdi Form Validating VB.NET ComboBox _SelectedIndexChanged TypeForwardedToApp attribute. text justification in excel ComboBox in DataGrid How to compare two identical tables in VB.NET + MS Access Determine projects in solution within VS2005 macro |
|||||||||||||||||||||||