Does anyone know a good example of creating a TreeView from a database? I have been able to get part of it done but I was not sure if I was heading in the right direction with this project. My next step is when I click on a node in the tree is to get the info from the database that is related to that node.
There's one that comes with the MSDN library, i'll attach it for you. The database it uses is 3MB though, I could upload it or e-mail if you wanted.
-adehh
Thanks for the code adzzzz I will take a look at it,
Here is what I came up with so far...
Code:
Private Sub tvCodeLibrary_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvCodeLibrary.AfterSelect
Dim NameID As Long
Dim MyAdapter As New OleDbDataAdapter
Dim MyDataset As New DataSet
Dim MyCommand As New OleDbCommand
Dim MyRow As DataRow
Me.txtDescription.Text = ""
Me.rtbCodeWindow.Text = ""
Me.txtNote.Text = ""
NameID = Me.tvCodeLibrary.SelectedNode.Tag
MyCommand = New OleDbCommand("SELECT Description, Code, Note from Code where ID = " & NameID, MyConnection)
MyAdapter = New OleDbDataAdapter(MyCommand)
MyAdapter.Fill(MyDataset, "Code")
For Each MyRow In MyDataset.Tables("Code").Rows
If IsDBNull(MyRow("Description")) <> True Then Me.txtDescription.Text = MyRow("Description")
If IsDBNull(MyRow("Code")) <> True Then Me.rtbCodeWindow.Text = MyRow("Code")
If IsDBNull(MyRow("Note")) <> True Then Me.txtNote.Text = MyRow("Note")
Next MyRow
MyDataset.Tables("Code").Clear()
End Sub