你這個(gè)要按照數(shù)據(jù)庫(kù)的查詢(xún)數(shù)據(jù)找出來(lái)根節(jié)點(diǎn)。Treeview增加一個(gè)節(jié)點(diǎn)。
專(zhuān)注于為中小企業(yè)提供成都網(wǎng)站建設(shè)、成都做網(wǎng)站服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)浮山免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了數(shù)千家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
然后根據(jù)根節(jié)點(diǎn)找出來(lái)所有子節(jié)點(diǎn)。再依次增加TreeView子節(jié)點(diǎn)。
然后逐個(gè)子節(jié)點(diǎn)進(jìn)行下一步查詢(xún)。再把結(jié)果刷新到TreeView子節(jié)點(diǎn)。
給你說(shuō)說(shuō)思路。你肯定會(huì)問(wèn)怎么編程序。
那麻煩你上網(wǎng)到msdn查查T(mén)reeview的例子程序,自己學(xué)習(xí)改改看看。
如果你還堅(jiān)持要?jiǎng)e人幫你寫(xiě)寫(xiě)數(shù)據(jù)庫(kù)查詢(xún)的代碼,那你也可以移步msdn查找SQLServer數(shù)據(jù)庫(kù)查詢(xún)?nèi)绾螆?zhí)行按照關(guān)鍵字查詢(xún)。
樹(shù)狀結(jié)構(gòu)使用treeview實(shí)現(xiàn),控件添加方法:右擊“工具箱”-“部件”-microsoft windows common controls 6.0-確定,應(yīng)用
下面是簡(jiǎn)單的添加刪除方法,
Option Explicit
‘添加項(xiàng)目
Private Sub Command1_Click()
Dim nodx As Node
Set nodx = TreeView1.Nodes.Add(, , "zf", "紫風(fēng)無(wú)痕關(guān)系(雙擊收起)")
Set nodx = TreeView1.Nodes.Add("zf", tvwChild, "zfwife", "老婆")
Set nodx = TreeView1.Nodes.Add("zf", tvwChild, "zflover", "情人")
Set nodx = TreeView1.Nodes.Add("zf", tvwChild, "zffriend", "朋友")
Set nodx = TreeView1.Nodes.Add("zfwife", tvwChild, "lp1", "大老婆")
Set nodx = TreeView1.Nodes.Add("zfwife", tvwChild, "lp2", "二老婆")
Set nodx = TreeView1.Nodes.Add("zfwife", tvwChild, "lp3", "三老婆")
Set nodx = TreeView1.Nodes.Add("zfwife", tvwChild, "lp4", "四老婆")
Set nodx = TreeView1.Nodes.Add("zfwife", tvwChild, "lp5", "五老婆")
Set nodx = TreeView1.Nodes.Add("zflover", tvwChild, "qr1", "1號(hào)情人")
Set nodx = TreeView1.Nodes.Add("zflover", tvwChild, "qr2", "2號(hào)情人")
Set nodx = TreeView1.Nodes.Add("zflover", tvwChild, "qr3", "3號(hào)情人")
Set nodx = TreeView1.Nodes.Add("zffriend", tvwChild, "py1", "張三")
Set nodx = TreeView1.Nodes.Add("zffriend", tvwChild, "py2", "李四")
Set nodx = TreeView1.Nodes.Add("zffriend", tvwChild, "py3", "王麻子")
Set nodx = TreeView1.Nodes.Add("py1", tvwChild, "pylp1", "張三的老婆")
Set nodx = TreeView1.Nodes.Add("py1", tvwChild, "pylp2", "張三的孩子")
nodx.EnsureVisible
End Sub
'刪除代碼
Private Sub Command2_Click()
MsgBox ("將要?jiǎng)h除" TreeView1.SelectedItem.Text)
TreeView1.Nodes.Remove (TreeView1.SelectedItem.Index)
End Sub
很簡(jiǎn)單,在頁(yè)面上拖個(gè)treeview,可以直接給它實(shí)裝數(shù)據(jù),運(yùn)行一下,就可展開(kāi)。