A lie-down or horizontal treeview from DB

Hi. I have written some codes that display a treeview of a database via ADO. Like all treeview, it is consisted of a vertical line with branches
coming out from left to right. I need the treeview to be "lying down" i.e.
a horizontal line with branches coming or going up from the line. I need to put a label on each of the nodes of branch out from the line upwards.

I would appreciate very much if anyone has any idea of how to do this.

Option Explicit

' The database connection.
Private m_Conn As ADODB.Connection
' List the records in this table.
Private Sub LoadRecords(ByVal table_node As Node)
Dim rs As ADODB.Recordset
Dim i As Integer
Dim record_text As String
Dim record_node As Node

' Do nothing if the table's records are already loaded.
If table_node.Children > 0 Then Exit Sub

' Get the table's records.
Set rs = m_Conn.Execute( _
"SELECT * FROM " & table_node.Text, , adCmdText)
Do Until rs.EOF
' Build the record string.
record_text = ""
For i = 0 To rs.Fields.Count - 1
record_text = record_text & ", " & rs.Fields.Item(i)
Next i
record_text = Mid$(record_text, 2)

' Add the record node.
Set record_node = trvData.Nodes.Add(table_node, tvwChild, , record_text)
record_node.Tag = "Record"

' Get the next record.

End Sub

' List the tables in the database.
Private Sub ListTables()
Dim rs As ADODB.Recordset
Dim table_node As Node

' Clear the TreeView.

' Use OpenSchema and get the table names.
' The final argument in the parameter array
' is "Table" to indicate we want a list of tables.
Set rs = m_Conn.OpenSchema(adSchemaTables, _
Array(Empty, Empty, Empty, "Table"))
Do While Not rs.EOF
Set table_node = trvData.Nodes.Add(, , , rs!TABLE_NAME)
table_node.Tag = "Table"

End Sub
Private Sub Form_Load()
Dim db_file As String

' Get the database file name.
db_file = App.Path
If Right$(db_file, 1) <> "" Then db_file = db_file & ""
db_file = db_file & "Data.mdb"

' Open the database connection.
Set m_Conn = New ADODB.Connection
m_Conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"

' Load the table names into the ListView.
End Sub
Private Sub Form_Resize()
trvData.Move 0, 0, ScaleWidth, ScaleHeight
End Sub

Private Sub Form_Unload(Cancel As Integer)
End Sub

Private Sub trvData_NodeClick(ByVal Node As MSComctlLib.Node)
' See what kind of node this is.
Select Case Node.Tag
Case "Table"
' Load this table's records.
LoadRecords Node
Case "Record"
MsgBox "Record" & Node.Text
End Select
End Sub
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!