7,762
社区成员
发帖
与我相关
我的任务
分享
Private Sub Form_Initialize()
Dim NodParent As Node
Dim NodChild As Node
With Me.TreeView1
.LineStyle = tvwRootLines
Set NodParent = .Nodes.Add(, , "r", "任务树")
Set NodChild = .Nodes.Add("r", tvwChild, "child1", "任务列表")
Set NodChild = .Nodes.Add("r", tvwChild, "child2", "数据库数据")
Set NodChild = .Nodes.Add("r", tvwChild, "child3", "SE数据")
End With
End Sub
以下是Gfrm01窗体下的代码
Private Sub TreeView1_Click()
Dim Indx As Variant
Dim tepFrm1 As Form, tepFrm2 As Form '注意:窗体变量赋值,防出错!!!!
Indx = TreeView1.SelectedItem.Key
Select Case Indx
Case "child2"
Gfrm02.Move MDIFrmG.Width / 3, 0, MDIFrmG.Width * 2 / 3, Me.Height
Set Gfrm02 = Nothing
Case "child3"
Gfrm03.Move MDIFrmG.Width / 3, 0, MDIFrmG.Width * 2 / 3, Me.Height
Set Gfrm03 = Nothing
End Select
End Sub
这样的结果是,随机反复点击treeview的item,出现的子窗体是对的。但是,所有的子窗体没有关上,而是在后面
关键是,这样的代码,有没有潜藏的隐患?Public FrmDetails As New FrmDetails
Public MDIForm1 As New MDIForm1
...