如何在子节点下再增加子节点?
解决方案 »
- 100分问题,兄弟们帮帮忙!
- Sql-->VB-->Excel,怎么可以让某些相同日期的字段求和后,再写入Excel
- 如何实现:在VB中点击一个按钮,则调出Windows自带的计算器?
- 如何得到另一个软件的列表框的内容?我用getText(该列表框的句柄)得不到,但是文本框就OK,不知为什么?
- 如果将VB生成的EXE文件反编译回去?
- 水晶报表究竟有多大?
- 关于共享
- 求教:有窗体form1,form2,form3
- 急求,UPDATE 语句的语法错误 解决办法!!
- 谁有GetOpenFileName函数的详细说明,谢谢!!!
- 问一个关于picture的打印的问题!!!不知道你以前做过没有??
- apple的machitoshi如何能运行VB编译的程序?
这个treeview1.nodes(k)就是你要在其下面加子节点的子节点: )
Private Sub Command1_Click()
If Text1.Text <> "" And Text2.Text <> "" Then '²»ÔÊÐí½¨Á¢Áã×ֽڵĸ¸½ÚµãºÍ×Ó½Úµã
CunZai = False
J = TreeView1.Nodes.Count
For i = 1 To TreeView1.Nodes.Count '¼ì²éÐÂÊäÈëµÄ¸¸½ÚµãÃû³ÆÊÇ·ñ´æÔÚ
If TreeView1.SelectedItem.Children > 0 Then
If Text1.Text = TreeView1.Nodes(i).Text Then CunZai = True
End If
Next i
If CunZai = True Then 'Èô´æÔÚ, ÔòÔÚ¸¸½ÚµãϽ¨Á¢×Ó½Úµã
Set nodx = TreeView1.Nodes.Add(Text1.Text, tvwChild, "child" & J, Text2.Text, 3)
Else 'Èô²»´æÔÚ,Ôò½¨Á¢¸¸½ÚµãºÍ×Ó½Úµã
Set nodx = TreeView1.Nodes.Add(, , Text1.Text, Text1.Text, 1)
Set nodx = TreeView1.Nodes.Add(Text1.Text, tvwChild, "child" & J, Text2.Text, 3)
End If
TreeView1.Refresh
ElseIf Text1.Text = "" Then MsgBox "ÇëÊäÈ븸½ÚµãÃû³Æ!", vbInformation, "¾¯¸æ£¡"
'ϵͳÌáʾ
ElseIf Text1.Text = "" Then MsgBox "ÇëÊäÈë×Ó½ÚµãÃû³Æ!", vbInformation, "¾¯¸æ£¡"
End If
End Sub
If Text1.Text <> "" And Text2.Text <> "" Then '判断父节点和子节点
CunZai = False
J = TreeView1.Nodes.Count
For i = 1 To TreeView1.Nodes.Count '检查新输入的父节点是否存在
If TreeView1.SelectedItem.Children > 0 Then
If Text1.Text = TreeView1.Nodes(i).Text Then CunZai = True
End If
Next i
If CunZai = True Then 若存在,则建立子节点 Set nodx = TreeView1.Nodes.Add(Text1.Text, tvwChild, "child" & J, Text2.Text, 3)
Else ‘若不存在,建立父节点和子节点
Set nodx = TreeView1.Nodes.Add(, , Text1.Text, Text1.Text, 1)
Set nodx = TreeView1.Nodes.Add(Text1.Text, tvwChild, "child" & J, Text2.Text, 3)
End If
TreeView1.Refresh
ElseIf Text1.Text = "" Then MsgBox "请输入父节点名称!", vbInformation, 警告¡"
'ϵͳÌáʾ
ElseIf Text1.Text = "" Then MsgBox "!请输入父节点名称", vbInformation, 警告£¡"
End If
End Sub