VB6.0中TreeView控件,如何点击节点切换右侧界面, 在同一窗体当中显示,求老师们指导,谢谢了
在VB6.0中TreeView控件,如何点击节点切换右侧界面,调用不同的界面,并且在同一窗体当中显示,该怎么编程,求老师们指导
Private Sub TreeView1_NodeClick(ByVal Node As Node) If (Node.Index - 1) > 0 And (Node.Index - 1) < 2000 Then If Not Val(XYID(Node.Index - 1)) <= 0 Then '连接数据库语句略 strSQL = "select * from 数据表 Where ID=" & Val(XYID(Node.Index - 1)) & "" 'XYID(Node.Index - 1)是获取记录的ID值 RS.Open strSQL, db, 3, 2 '这里就是右侧界面中数据的不同界面显示的代码,由于不清楚你的右侧界面,不能具体回答。 RS.Close db.Close End If End If End Sub
Dim ZCYMC(1 To 15) As String Private Sub Form_Load() Dim Nodx As Node Set Nodx = TreeView1.Nodes.Add() Nodx.Text = "主树干" TreeView1.LabelEdit = tvwManual Set Nodx = TreeView1.Nodes.Add(1, tvwChild, "A", "树干1") Set Nodx = TreeView1.Nodes.Add("A", tvwChild) Nodx.Text = "树叶11" ZCYMC(Nodx.Index) = "树叶11" Set Nodx = TreeView1.Nodes.Add("A", tvwChild) Nodx.Text = "树叶12" ZCYMC(Nodx.Index) = "树叶12" Set Nodx = TreeView1.Nodes.Add("A", tvwChild) Nodx.Text = "树叶13" ZCYMC(Nodx.Index) = "树叶13" Set Nodx = TreeView1.Nodes.Add(1, tvwChild, "B", "树干2") Set Nodx = TreeView1.Nodes.Add("B", tvwChild) Nodx.Text = "树叶21" ZCYMC(Nodx.Index) = "树叶21" Set Nodx = TreeView1.Nodes.Add("B", tvwChild) Nodx.Text = "树叶22" ZCYMC(Nodx.Index) = "树叶22" Set Nodx = TreeView1.Nodes.Add("B", tvwChild) Nodx.Text = "树叶23" ZCYMC(Nodx.Index) = "树叶23" Set Nodx = TreeView1.Nodes.Add(1, tvwChild, "C", "树干3") Set Nodx = TreeView1.Nodes.Add("C", tvwChild) Nodx.Text = "树叶31" ZCYMC(Nodx.Index) = "树叶31" Set Nodx = TreeView1.Nodes.Add("C", tvwChild) Nodx.Text = "树叶32" ZCYMC(Nodx.Index) = "树叶32" Set Nodx = TreeView1.Nodes.Add("C", tvwChild) Nodx.Text = "树叶33" ZCYMC(Nodx.Index) = "树叶33" Nodx.EnsureVisible TreeView1.StartLabelEdit End Sub Private Sub TreeView1_NodeClick(ByVal Node As Node) If (Node.Index - 1) >= 0 And (Node.Index - 1) <= 15 Then Dim AAA As String AAA = ZCYMC(Node.Index) Text1.Text = AAA '这样你应该知道怎么在右边显示了吧? End If End Sub
[此贴子已经被作者于2018-1-3 17:17编辑过]