C
Co
Hi All,
I'm a newbie at VB.net and I'm having trouble with a treeview and a
database connection.
I have an access database with a table called "Kabinet". I want to use
this table to fill my treeview.
Table Kabinet:
Id (autonum)
folder (text)
parent-id (num)
The records in the table:
1 Kabinet
2 Subfolder 1
3 Subfolder 1
4 Subfolder 1
5 Subsubfolder 2
6 Subsubfolder 3
7 Subsubsubfolder 6
Now I want to fill the treeview with "Kabinet"in the root and
underneath the next levels.
Dim sql = "SELECT * FROM Kabinet"
Dim cmd As New OleDbCommand(sql, conn)
Dim dr As System.Data.OleDb.OleDbDataReader
conn.Open()
dr = cmd.ExecuteReader()
While dr.Read()
tvRoot = Me.TreeView.Nodes.Add(dr.Item("folder"))
End While
dr.Close()
I need something to make sure the records go to the right level in the
treeview so:
Kabinet
|---------- Subfolder
| |------Subsubfolder
|-----------Subfolder
| |------Subsubfolder
| |------Subsubsubfolder
|-----------Subfolder
Also the code should be so that when I add a ....subfolder that it
will go to the right folder.
So the amount of levels should be n -deep.
Regards
Marco
I'm a newbie at VB.net and I'm having trouble with a treeview and a
database connection.
I have an access database with a table called "Kabinet". I want to use
this table to fill my treeview.
Table Kabinet:
Id (autonum)
folder (text)
parent-id (num)
The records in the table:
1 Kabinet
2 Subfolder 1
3 Subfolder 1
4 Subfolder 1
5 Subsubfolder 2
6 Subsubfolder 3
7 Subsubsubfolder 6
Now I want to fill the treeview with "Kabinet"in the root and
underneath the next levels.
Dim sql = "SELECT * FROM Kabinet"
Dim cmd As New OleDbCommand(sql, conn)
Dim dr As System.Data.OleDb.OleDbDataReader
conn.Open()
dr = cmd.ExecuteReader()
While dr.Read()
tvRoot = Me.TreeView.Nodes.Add(dr.Item("folder"))
End While
dr.Close()
I need something to make sure the records go to the right level in the
treeview so:
Kabinet
|---------- Subfolder
| |------Subsubfolder
|-----------Subfolder
| |------Subsubfolder
| |------Subsubsubfolder
|-----------Subfolder
Also the code should be so that when I add a ....subfolder that it
will go to the right folder.
So the amount of levels should be n -deep.
Regards
Marco