Dim one As Node, two As Node, three As Node, four As Node, five As NodePrivate Sub Form_Load()   TreeView1.LineStyle = tvwRootLines
   TreeView1.ImageList = ImageList1
   TreeView1.Style = tvwTreelinesPlusMinusPictureText
   
   Set one = TreeView1.Nodes.Add(, , "one", "系统管理", 1)
   one.Expanded = False
   Set one = TreeView1.Nodes.Add("one", tvwChild, "child1", "基础设置", 2)
   Set one = TreeView1.Nodes.Add("one", tvwChild, "child2", "通讯设置", 1)
   Set one = TreeView1.Nodes.Add("one", tvwChild, "child3", "用户管理", 1)
   Set one = TreeView1.Nodes.Add("one", tvwChild, "child4", "登陆/注销", 1)
   Set one = TreeView1.Nodes.Add("one", tvwChild, "child5", "退出系统", 1)
   
   Set two = TreeView1.Nodes.Add(, , "two", "参数设置", 2)
   one.Expanded = False
   Set two = TreeView1.Nodes.Add("two", tvwChild, "child6", "基本参数", 2)
   Set two = TreeView1.Nodes.Add("two", tvwChild, "child7", "校正参数", 2)
   Set two = TreeView1.Nodes.Add("two", tvwChild, "child8", "运行参数", 2)
   Set two = TreeView1.Nodes.Add("two", tvwChild, "child9", "背景参数", 2)
   Set two = TreeView1.Nodes.Add("two", tvwChild, "child10", "曲线修正", 2)
   Set two = TreeView1.Nodes.Add("two", tvwChild, "child11", "上传/下载背景", 2)
   Set two = TreeView1.Nodes.Add("two", tvwChild, "child12", "斜率截距计算", 2)上面的代码,我想每一个子节点都对应一个窗体事件. 应该怎么办?
是在 TreeView1_BeforeLabelEdit 怎么写呢?谢谢...急等. 以前没有搞过VB第一次碰到.

解决方案 »

  1.   

    Private Sub Form_Load()  TreeView1.LineStyle = tvwRootLines
      TreeView1.ImageList = ImageList1
      TreeView1.Style = tvwTreelinesPlusMinusPictureText
      
      Set one = TreeView1.Nodes.Add(, , "one", "系统管理", 1)
      one.Expanded = False
      Set one = TreeView1.Nodes.Add("one", tvwChild, "child1", "基础设置", 2)
      Set one = TreeView1.Nodes.Add("one", tvwChild, "child2", "通讯设置", 1)
      Set one = TreeView1.Nodes.Add("one", tvwChild, "child3", "用户管理", 1)
      Set one = TreeView1.Nodes.Add("one", tvwChild, "child4", "登陆/注销", 1)
      Set one = TreeView1.Nodes.Add("one", tvwChild, "child5", "退出系统", 1)
      
      Set two = TreeView1.Nodes.Add(, , "two", "参数设置", 2)
      one.Expanded = False
      Set two = TreeView1.Nodes.Add("two", tvwChild, "child6", "基本参数", 2)
      Set two = TreeView1.Nodes.Add("two", tvwChild, "child7", "校正参数", 2)
      Set two = TreeView1.Nodes.Add("two", tvwChild, "child8", "运行参数", 2)
      Set two = TreeView1.Nodes.Add("two", tvwChild, "child9", "背景参数", 2)
      Set two = TreeView1.Nodes.Add("two", tvwChild, "child10", "曲线修正", 2)
      Set two = TreeView1.Nodes.Add("two", tvwChild, "child11", "上传/下载背景", 2)
      Set two = TreeView1.Nodes.Add("two", tvwChild, "child12", "斜率截距计算", 2)
    End SubPrivate Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
        Select Case Node.Key
            Case "child1"
                Form2.Show
            Case "child2"
                '等等你要显示的窗体
        End Select
        
    End Sub
      

  2.   

    哈哈,谢谢LZ我的也解决啦,也要感谢楼上 o(∩_∩)o...