'说明:很多功能都还没有收集完,还在完善中...
'新建一个"code.ini"文本文档,将文本一行行写入文本文档中(第一个层次分隔符以"#"号打头)
'举例:
'#gml##根目录
'#yjzml##一级子目录
'#ejzml##二级子目录
'#sjzml##三级子目录
'层次等级排列必须从大到小排列(例子中"根目录"最大,"三级子目录"最小,不能跨级排列)
Dim zifu As String '装载所有代码内容
Dim genmulu As Integer '根目录编号
Dim yijizimulu As Integer '一级子目录编号
Dim erjizimulu As Integer '二级子目录编号
Dim sanjizimulu As Integer '三级子目录编号
'Dim sijizimulu As Integer '四级子目录编号
Private Sub Form_Load() '将数据导入到TreeView控件中
TreeView1.LineStyle = tvwRootLines 'node对像之间显示的行样式
TreeView1.Indentation = 300 '树视图控件的缩进宽度
'--------------------------------------------------------------------------------------------------------TreeView基本设置
Open App.Path & "\" & "code.ini" For Binary As #1
zifu = Input(LOF(1), 1)
Close #1
'--------------------------------------------------------------------------------------------------------加载内容到字符串变量中
Dim a
Dim i As Integer
a = Split(zifu, vbCrLf)
For i = LBound(a) To UBound(a)
If Left(a(i), 6) = "#gml##" Then
genmulu = genmulu + 1
TreeView1.Nodes.Add , , "genmulu" & genmulu, Split(Split(a(i), "##")(1), "#")(0)
'------------------------------------------------------------------------------------------------新建根目录
End If
If Left(a(i), 8) = "#yjzml##" Then
yijizimulu = yijizimulu + 1
TreeView1.Nodes.Add "genmulu" & genmulu, tvwChild, "yijizimulu" & yijizimulu, Split(Split(a(i), "##")(1), "#")(0)
'------------------------------------------------------------------------------------------------新建一级子目录
End If
If Left(a(i), 8) = "#ejzml##" Then
erjizimulu = erjizimulu + 1
TreeView1.Nodes.Add "yijizimulu" & yijizimulu, tvwChild, "erjizimulu" & erjizimulu, Split(Split(a(i), "##")(1), "#")(0)
'------------------------------------------------------------------------------------------------新建二级子目录
End If
If Left(a(i), 8) = "#sjzml##" Then
sanjizimulu = sanjizimulu + 1
TreeView1.Nodes.Add "erjizimulu" & erjizimulu, tvwChild, "sanjizimulu" & sanjizimulu, Split(Split(a(i), "##")(1), "#")(0)
'------------------------------------------------------------------------------------------------新建三级子目录
End If
Next i
'--------------------------------------------------------------------------------------------------------将符合条件的内容导入控件
'For Each Node In TreeView1.Nodes
'Node.Expanded = True
'Next
'--------------------------------------------------------------------------------------------------------展开目录树
'TreeView1.SelectedItem.Text'当前选中行的文字
'ListView1.ListItems.Count '总行数
End Sub