回覆列表
  • 1 # 使用者9272196178563

    樹狀結構使用treeview實現,控制元件新增方法:右擊“工具箱”-“部件”-microsoft windows common controls 6.0-確定,應用下面是簡單的新增刪除方法,Option Explicit‘新增專案Private Sub Command1_Click()Dim nodx As NodeSet nodx = TreeView1.Nodes.Add(, , "zf", "紫風無痕關係(雙擊收起)")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號情人")Set nodx = TreeView1.Nodes.Add("zflover", tvwChild, "qr2", "2號情人")Set nodx = TreeView1.Nodes.Add("zflover", tvwChild, "qr3", "3號情人")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.EnsureVisibleEnd Sub"刪除程式碼Private Sub Command2_Click()MsgBox ("將要刪除" & TreeView1.SelectedItem.Text)TreeView1.Nodes.Remove (TreeView1.SelectedItem.Index)End Sub

  • 中秋節和大豐收的關聯?
  • 到了六十歲,疾病總要伴你前行,你會把它當朋友嗎?