mdltreeview.bas

来自「利用VB和ACESS联合制作的一个人事和物品管理系统」· BAS 代码 · 共 44 行

BAS
44
字号
Attribute VB_Name = "mdlTreeView"
Option Explicit
Dim fso As New FileSystemObject


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'将对象加入控件的所有函数

'将所有类型加入树型图
Public Sub TypeToTreeview(ByRef tvw As TreeView)
  Dim objs As New clsITypes
  Dim i As Long
  Dim sDir As String
  Dim sDirectory As String
  '先加入没有上级客户类型的客户类型
  objs.Find
  Dim Nd As Node
  '加入原始根节点。“O0”中,第一个为字母O,第二个为数字0
  Set Nd = tvw.Nodes.Add(, , "O0", "所有图像类型", "group2")
  Nd.Expanded = True
  Nd.Selected = True
  
  For i = 1 To objs.Count
    '加入没有上级客户类型的客户类型节点,图形列表ID为“D”
    Set Nd = tvw.Nodes.Add("O0", tvwChild, "A" & objs.Item(i).ID, _
                          objs.Item(i).TypeName, "group")
    Nd.Expanded = True
    sDir = objs.Item(i).TypeName
    sDirectory = App.Path & "\图像\" & sDir
    sDirectory = CheckPath(sDirectory)
     If fso.FolderExists(sDirectory) = False Then
       fso.CreateFolder (sDirectory)
     End If
  Next i
End Sub


'得到某个节点或列表项所表示的对象的实际ID,如“A11”,则得到11,“B2”,则得到2
Public Function GetID(strKey As String) As Long
  GetID = Val(Right(strKey, Len(strKey) - 1))
End Function
'

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?