我想用TREEVIEW做一个二层的树形菜单,就如CSDN本论坛的导行栏一样,但结点随时更新,只能从数据库里分类加载,下面是我加载根结点的代码,运行成功!
但不知怎么分类加载子结点?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dtr As System.Data.OleDb.OleDbDataReader
Dim cmd As System.Data.OleDb.OleDbCommand
TreeView1.Nodes.Clear()
cmd = New OleDb.OleDbCommand("select * from title", OleDbConnection1)
OleDbConnection1.Open()
dtr = cmd.ExecuteReader()
Dim n As Integer
While dtr.Read()
If dtr.GetBoolean(2) = True Then
TreeView1.Nodes.Add(New TreeNode(dtr.GetString(1)))
End If
End While
dtr.Close()
OleDbDataAdapter1.Fill(DataSet11)
OleDbConnection1.Close()
End Sub