分享
 
 
 

vbscript版的TreeView,也就是树

王朝vb·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

'=======================================================

'===efei Super TreeView

'===Code By efei(草不含羞)

'===Mailto:efei731@sina.com

'===2004.7

'=======================================================

Dim tvwRoot

Dim tvwChild

Dim tvwPrevious

Dim tvwNext

tvwRoot = 0

tvwChild = 1

tvwPrevious = 2

tvwNext = 3

'===树的类

Class TreeView

?Public Name???'对象名

?Public TreeView_Name

?

?Private ArrNodes??'节点集合,从0开始

?

?Private ArrImage??'图标数组

?

?

?

?

?Private AddFromExpand??'节点的添加是否来自于父节点的展开

?

?'===一些设置

?

?Public FirstDisplayLevel?'初次显示几层

?Public UseConnectLine??'使用节点之间的连接线

?'Public ImagePath???'图象目录

?Public Target????'链接目标

?Public Font_Size???'文字大小

?Public Font_Family???'字体

?Public Font_Color???'颜色

?Public SelectedBgcolor??'选中的节点背景色

?

?'===图象目录=============================

?Private lImagePath???

?Public Property Get ImagePath()

??ImagePath = lImagePath

?End Property

?Public Property Let ImagePath(ByVal vNewValue)

??'更新之前先去掉原来的节点的边框

??lImagePath = vNewValue

??If Right(lImagePath,1) "/" Then lImagePath = lImagePath & "/"

?End Property

?'========================================

?

?Private lSelectedNode??'被选择的节点

?Public Property Get SelectedNode()

??Set SelectedNode = lSelectedNode

?End Property

?Public Property Let SelectedNode(ByVal vNewValue)

??'更新之前先去掉原来的节点的边框

??If Not lSelectedNode Is Nothing Then

???With Document.getElementById("txt" & lSelectedNode.Key).style

????.background = ""

???End With

??End If

??Set lSelectedNode = vNewValue

??With Document.getElementById("txt" & lSelectedNode.Key).style

???.background = SelectedBgcolor

??End With

?End Property

?

?Private lMenuNode

?Private lPopupMenu

?

?'===类的析构函数,用于初始化对象==============

?Private Sub Class_Initialize()

??'===初始化树对象

??Document.Write ""

??'===

??Redim ArrNodes(0)

??Set ArrNodes(0) = Nothing

??name=""

??TreeView_Name = "Efei Super TreeView"

??

??Set lSelectedNode = Nothing

??Set lMenuNode = Nothing

??lPopupMenu = ""

??

??Redim ArrImage(1,2)

??ArrImage(0,0) = "FolderClose"

??ArrImage(1,0) = "FolderClose.gif"

??ArrImage(0,1) = "FolderOpen"

??ArrImage(1,1) = "FolderOpen.gif"

??ArrImage(0,2) = "Rplus"

??ArrImage(1,2) = "Rplus.gif"

??AddImage "root","root.gif"

??AddImage "file","file.gif"

??

??lImagePath = "Image/"

??FirstDisplayLevel = 0

??UseConnectLine = True

??AddFromExpand = False

??Target = "_Blank"

??

??Font_Size = "12px"

??Font_Family = "宋体"

??Font_Color = "#000000"

??SelectedBgcolor = "#D4D0C8"

??

?End Sub

?'===============================================

?

?'===功能:?添加一个节点

?'===参数:?Text???节点显示的文本

?'???Key????节点关键字,该关键字必须唯一

?'???HyperLink??节点要链接到的地址

?'???Node???父节点或者兄弟节点

?'???AddType???添加类型,0-子节点,1-子节点,2-前置节点,3-后置节点

?'???Image???节点的图片,如空,则使用关闭的文件夹

?Public Function add(ByVal Text,ByVal Key,ByVal HyperLink,ByRef Node,ByVal AddType,ByVal Image)

??Dim i

??'先检查关键字是否已存在,参数是否合法

??Key = Trim(Key)

??If Key = "" Then

???Msgbox "关键字不能为空",vbInformation,TreeView_Name

???Exit Function

??End If

??If NOT Me.Nodes(Key) Is Nothing Then

???Msgbox "关键字【" & Key & "】已存在",vbInformation,TreeView_Name

???Exit Function

??End If

??Text = Trim(Text)

??If Text = "" Then

???Msgbox "节点文本不能为空",vbInformation,TreeView_Name

???Exit Function

??End If

??If IsNumeric(AddType) = True Then

???If AddType 3 Then

????AddType = 1

???End If

??Else

???AddType = 1

??End If

??If Node Is Nothing Then

???If Me.NodesCount 0 Then

????Msgbox "根节点只能有一个",vbInformation,TreeView_Name

????Exit Function

???End If

???AddType = 0

??End IF

???

??Redim Preserve ArrNodes(Me.NodesCount)

??Set ArrNodes(Ubound(ArrNodes)) = New Node

??

??

??

??With ArrNodes(Ubound(ArrNodes))

???.Key = Key

???.Text=Text

???.HyperLink=HyperLink

???

???.AddType = AddType

???.Image = Image

???Set .parentObject = Me

???

???

???Select Case AddType

????Case 0??'根节点

?????Set .ParentNode=Nothing

?????Set .NextNode = Nothing

????Case 1??'子节点

?????Set .ParentNode = Node??????'父节点

?????If Node.ChildrenCount 0 Then

??????Set .PreviousNode = Node.Children(Node.ChildrenCount)

??????Set Node.Children(Node.ChildrenCount).NextNode = ArrNodes(Ubound(ArrNodes))

?????End If

?????Set .NextNode = Nothing

????Case 2??'插在前面

?????Set .ParentNode = Node.ParentNode

?????Set .PreviousNode = Node.PreviousNode

?????Set Node.PreviousNode.NextNode = ArrNodes(Ubound(ArrNodes))

?????Set Node.PreviousNode = ArrNodes(Ubound(ArrNodes))

?????Set .NextNode = Node

?????

????Case 3??'插在后面

?????Set .ParentNode = Node.ParentNode

?????Set .PreviousNode = Node

?????Set .NextNode = Node.NextNode

?????Set Node.NextNode = ArrNodes(Ubound(ArrNodes))

???End Select

???If Not .ParentNode Is Nothing Then

????'更新父节点的内容

????.Level = .ParentNode.Level + 1

????

????.ParentNode.AddChild ArrNodes(Ubound(ArrNodes))??'添加子节点

???End If

???'If Image "" Then

???'?.Image = Me.Images(Image)

???'End If

???

???.Display

???

???

???If .Level Me.FirstDisplayLevel Then

????.DisplayStatus = 0

???Else

????If NOT .ParentNode Is Nothing AND AddFromExpand = False Then

?????If .ParentNode.ExpandStatus = 0 Then

??????.ParentNode.ExpandStatus = 1??'自己都显示了,那说明父节点肯定是展开的

?????End If

????End If

????.DisplayStatus = 1

????

???End If

???

???

???

???

???If NOT .ParentNode Is Nothing Then??

????RefreshImage .ParentNode????

???End If

???'=================

??End With

??Set add = ArrNodes(UBound(ArrNodes))

?End Function

?'==============================================================================================

?

?

?'===功能:?移除一个节点,包括该节点下的所有子节点=============================================

?'===参数:?Key???节点的Key,或者是顺序号

?Public Function RemoveNode(ByVal Key)

??Dim i

??Dim Node

??Set Node = Nothing

??Key = Trim(Key)

??If Key = "" Then

???Exit Function

??End IF

??If IsNumeric(Key) = True Then

???If Key 0 And Key

????Set Node = Nodes(Key)

???End If

??Else

???Set Node = Nodes(Key)

??End If

??If Node Is Nothing Then

???Exit Function

??End If

??Do Until Node.ChildrenCount = 0

???RemoveNode Node.Children(1).Key

??Loop

??

??If Not Node.PreviousNode Is Nothing Then

???'如果有前置节点,则要重新设置前置节点的后置节点

???Set Node.PreviousNode.NextNode = Node.NextNode

??End If

??If Not Node.NextNode Is Nothing Then

???'如果有后置节点,则要重新设置后置节点的前置节点

???Set Node.NextNode.previousNode = Node.PreviousNode

??End If

??

??'===设置它的父节点的子节点内容================================

??With Node.ParentNode

???

???For i = 0 To .ChildrenCount - 1

????If .ChildrenNodes(i).Key = Key Then

?????Exit For

????End If

???Next

???For i = i To .ChildrenCount - 2

????Set .ChildrenNodes(i) = .ChildrenNodes(i+1)

???Next

???.ChildrenCount = .ChildrenCount - 1

???Redim Preserve ChildrenNodes(.ChildrenCount - 1)

??End With

??'=============================================================

??

??'===设置树对象的节点集合======================================

??For i = 0 To Ubound(ArrNodes)

???If ArrNodes(i).Key = Key Then Exit For

??Next

??For i = i To Ubound(ArrNodes) - 1

???Set ArrNodes(i) = ArrNodes(i+1)

??Next

??Redim Preserve ArrNodes(Ubound(ArrNodes)-1)

??'==============================================================??

??

??Set Node = Document.getElementByID(Key).parentElement.parentElement

??Node.ParentElement.parentElement.deleteRow Node.rowIndex

??

??

??

??Set Node = Nothing

?End Function

?'==============================================================================================

?

?

?

?'===Nodes集合,返回一个节点,如果没有,返回Nothing========

?Public Function Nodes(index)

??dim i

??Set Nodes = Nothing

??If IsNumeric(index) = True Then

???If Ubound(ArrNodes)+1 = index And index 0 Then

????Set Nodes = ArrNodes(index - 1)

???End If

??Else

???If Ubound(ArrNodes) = 0 And ArrNodes(0) Is Nothing Then

????

???Else

????For i=0 to Ubound(ArrNodes)

?????If ArrNodes(i).Key = index Then

??????Set Nodes = ArrNodes(i)

?????End If

????Next

???End If

??End If

?End Function

?'==========================================================

?

?Public Property Get NodesCount()

??If Ubound(ArrNodes) = 0 And ArrNodes(0) Is Nothing Then

???NodesCount = 0

??Else

???NodesCount = Ubound(ArrNodes) + 1

??End If

?End Property

?Public Property Let NodesCount(ByVal vNewValue)

??Msgbox "NodesCount属性只读!"

?End Property

?

?'===功能:?清空图标集合=====================================

?Public Function ClearAllImage()

??Redim ArrImage(1,0)

?End Function

?'===End======================================================

?

?'===功能:?添加图标集合=====================================

?'???如果关键字imgKey存在,则更新,如不存在,则添加

?'===参数:?imgKey??图标关键字

?'???imgSrc??图标的名称

?Public Function AddImage(ByVal imgKey,ByVal imgFileName)

??dim i

??For i=1 To Ubound(ArrImage,2)

???If ArrImage(0,i) = imgKey Then

????ArrImage(1,i) = imgFileName??'更新

????Exit Function

???End If

??Next

??'添加

??If IsNumeric(imgFileName) = True Then

???Msgbox "图标关键字不能为纯数字!请使用字母或字母和数字的组合。"

???Exit Function

??End If

??i = Ubound(ArrImage,2)+1

??Redim Preserve ArrImage(1,i)

??ArrImage(0,i) = imgKey

??ArrImage(1,i) = imgFileName

?End Function

?'===End======================================================

?

?'===功能:?根据关键字来得到图标的路径=======================

?'===参数:?imgKey??图标的关键字,或是索引。索引从1开始

?Function Images(ByVal imgKey)

??Dim i

??Images = ""

??If imgKey = "" Then Exit Function

??If IsNumeric(imgKey) = True Then

???If Cint(imgKey) 0 Then

????Images = Me.ImagePath & ArrImage(1,imgKey)

???End If

??Else

???For i = 1 To Ubound(ArrImage,2)

????If Ucase(ArrImage(0,i)) = Ucase(imgKey) Then

?????Images = Me.ImagePath & ArrImage(1,i)

?????Exit For

????End If

???Next

??End If

?End Function

?'===End=======================================================

?

?'===动态更新各个节点前的连接线符号=============================

?Function RefreshImage(ByRef objNode)

??Dim i,j

??objNode.ExpandStatus = objNode.ExpandStatus

??Dim objTemp

??

??If NOT UseConnectLine Then Exit Function

??

??For i = 1 To objNode.ChildrenCount??'对子节点进行遍历

???Set objTemp = objNode.Children(i)

???For j = objNode.Level To 1 Step -1

????If NOT objTemp.ParentNode Is Nothing Then

?????Set objTemp = objTemp.ParentNode

?????If NOT objTemp.NextNode Is Nothing Then

??????Document.getElementById(objNode.Children(i).Key).rows(0).cells(j).firstChild.src = Me.ImagePath & "I.gif"?

?????End If

????End If

???Next

???RefreshImage objNode.Children(i)

??Next

?End Function

?'===End=========================================================

?

?'===展开或收起节点

?Public Function Expand(objNode)

??On Error Resume Next

??Dim ChildrenCount

??Dim Name

??Dim i

??

??

??

??ChildrenCount = objNode.ChildrenCount

??Name = Me.Name

??AddFromExpand = True??'在这里,如果外部在事件中给其他的节点添加了子节点,还是会出错,因此不能依赖于外部代码,还要改进

??TreeView_Expand Name,objNode

??AddFromExpand = False

??On Error Goto 0

??

??'===取得要显示/隐藏的最后一个接点的关键字

??Dim ArrIndex??'定义一个存放要操作的行索引的数组

??Dim FirstIndex,LastIndex

??FirstIndex = Document.getElementById(objNode.Key).parentElement.parentElement.rowIndex + 1

??

??Dim obj

??

??Redim ArrIndex(0)

??

??Dim tm

??tm = timer()

??

??If objNode.ExpandStatus = 0 Then

???objNode.ExpandStatus = 1

???If objNode.NextNode Is Nothing Then

????Set obj = ObjNode

????Do Until NOT obj.NextNode Is Nothing

?????Set obj = obj.parentNode

?????If obj Is Nothing Then Exit Do

????Loop

????If obj Is Nothing Then

?????LastIndex = Document.getElementById("TabTreeView").rows.length - 1

????Else

?????LastIndex = Document.getElementById(obj.NextNode.Key).parentElement.parentElement.rowIndex -1

????End If

???Else

????'===有下一个节点

????LastIndex = Document.getElementById(objNode.NextNode.Key).parentElement.parentElement.rowIndex -1

???End If

???

???Dim strAllKey?'存放所有要显示的节点的Key,用“,”隔开

???strAllKey = objNode.Key & ","

???For i = FirstIndex To LastIndex

????NodeKey = Document.getElementById("TabTreeView").rows(i).cells(0).firstChild.id

????If Instr(strAllKey,Me.Nodes(NodeKey).parentNode.key & ",") 0 And CBool(Me.Nodes(NodeKey).parentNode.ExpandStatus) Then

?????Redim Preserve ArrIndex(Ubound(ArrIndex)+1)

?????ArrIndex(Ubound(ArrIndex)) = i

?????strAllKey = strAllKey & NodeKey & ","

????End If

???Next

??ElseIf objNode.ExpandStatus = 1 Then

???'收起

???objNode.ExpandStatus = 0

???If objNode.NextNode Is Nothing Then

????Set obj = ObjNode

????Do Until NOT obj.NextNode Is Nothing

?????Set obj = obj.parentNode

?????If obj Is Nothing Then Exit Do

????Loop

????If obj Is Nothing Then

?????LastIndex = Document.getElementById("TabTreeView").rows.length - 1

????Else

?????LastIndex = Document.getElementById(obj.NextNode.Key).parentElement.parentElement.rowIndex -1

????End If

???Else

????'===有下一个节点

????LastIndex = Document.getElementById(objNode.NextNode.Key).parentElement.parentElement.rowIndex -1

???End If

???For i = FirstIndex To LastIndex

????Redim Preserve ArrIndex(Ubound(ArrIndex)+1)

????ArrIndex(Ubound(ArrIndex)) = i

???Next

??End If

??

??Dim NodeKey

??

??For i = 1 To Ubound(ArrIndex)

???NodeKey = Document.getElementById("TabTreeView").rows(ArrIndex(i)).cells(0).firstChild.id

???Me.Nodes(NodeKey).DisplayStatus = objNode.ExpandStatus

??Next

??

??'msgbox timer()-tm & Me.NodesCount

?End Function

?

?

?

?

?

?

?Public Property Get usePopupMenu()

??usePopupMenu = lPopupMenu

?End Property

?Public Property Let usePopupMenu(ByVal vNewValue)

??If lPopupMenu = "" Then

???Document.Write "" _

?????& "" _

?????& "

" _

?????& "

" _

?????& "" _

?????& "

"

???

??End If

??lPopupMenu = vNewValue

?End Property

?

?

?'===显示菜单===================================================

?Public Function ShowMenu()

??If lPopupMenu = "" Then

???ShowMenu = True

???HideMenu

???Exit Function

??End If?

??dim obj

??on error resume next

??

??Set obj = window.event.srcElement

??set obj = window.event.srcElement.parentElement.parentElement.parentElement.parentElement

??If Err.number0 Then

???ShowMenu = True

???HideMenu

???Exit Function

??End If

??'if window.event.srcElement.tagName = "IMG" Or window.event.srcElement.tagName = "A" Or window.event.srcElement.tagName = "TEXTAREA" Or window.event.srcElement.tagName = "INPUT" Then

??

??If Me.Nodes(obj.id) Is Nothing Or window.event.srcElement.tagName "LABEL" And window.event.srcElement.tagName "A" Then

???ShowMenu = True

???HideMenu

???Exit Function

??else

???'===要弹出菜单了,触发TreeView_BeforeShowMenu事件

???'事件原型:TreeView_BeforeShowMenu(Name,objNode,Cancel)

???Dim blnCancel

???On Error Resume Next

???blnCancel = False

???TreeView_BeforeShowMenu Me.Name,me.Nodes(obj.ID),blnCancel

???Err.Clear

???On Error Goto 0

???If CBool(blnCancel) = True Then

????'用户取消显示菜单

????ShowMenu = True

????HideMenu

????Exit Function

???End If

???

???

???Set lMenuNode = Me.Nodes(obj.id)

???

???Set obj = document.getElementById("Efei_TreeView_Menu")

???if window.event.clientX + 150 document.body.clientWidth Then

????obj.style.left = window.event.clientX? + document.body.scrollLeft

???else

????obj.style.left = window.event.clientX+document.body.scrollLeft

???End If

???If window.event.clientY + 100 document.body.clientHeight Then

????obj.style.top = window.event.clientY + document.body.scrollTop - 100

???else

????obj.style.top = window.event.clientY + document.body.scrollTop

???End If

???obj.style.display=""

??end If

??ShowMenu = False

?End Function

?'==============================================================

?

?'===隐藏菜单===================================================

?Public Function HideMenu()

??If lPopupMenu = "" Then

???Exit Function

??End If?

??Set lMenuNode = Nothing

??document.getElementById("Efei_TreeView_Menu").style.display="none"

?End Function

?'==============================================================

?

?'===添加菜单子项================================================

?Public Function AddMenu(ByVal strKey,ByVal strText)

??If lPopupMenu = "" Then

???Msgbox "右键菜单功能没有开启!",vbInformation+vbOKOnly,Me.TreeView_Name

???Exit Function

??End If

??strKey = Trim(strKey)

??strText = Trim(strText)

??If strKey = "" then

???Msgbox "菜单关键字不得为空!",vbInformation+vbOKOnly,Me.TreeView_Name

???Exit Function

??End If

??If strText = "" then

???Msgbox "菜单文本不得为空!",vbInformation+vbOKOnly,Me.TreeView_Name

???Exit Function

??End If

??Dim obj

??Set obj = document.getElementById("Efei_TreeView_Menu").firstChild.rows(0).cells(1).firstChild

??

??Dim objRow,objCell

??

??Set objRow = obj.insertRow(obj.rows.length-1)

??objRow.style.color="red"

??Set objCell = objRow.insertCell()

??If strText = "-" Then

???objCell.innerHTML = ""

??Else

???objCell.innerHTML = "" & strText & "

"

??End If

?End Function

?'===============================================================

?

?'===功能:?设置菜单子项的可见性======================================

?Function SetMenuVisibility(byVal Key,ByVal Value)

??If CBool(Value) = False Then

???Document.getElementById(Key).parentElement.parentElement.style.display = "None"

??Else

???Document.getElementById(Key).parentElement.parentElement.style.display = ""

??End If

?End Function

?'=====================================================================

?

?'===功能:?设置菜单子项的可用性======================================

?Function SetMenuEnable(byVal Key,ByVal Value)

??Document.getElementById(Key).parentElement.parentElement.disabled = Not CBool(Value)

?End Function

?'=====================================================================

?

?'===鼠标

?Sub ModifyStyle(objKey,OperType)

??on error resume next

??If OperType = "over" Then

???With document.getElementById(objKey).style

????.background = "highlight"

????.color = "highlighttext"

????

????.cursor = "default"

???End With

??ElseIf OperType = "out" Then

???With document.getElementById(objKey).style

????.background = "buttonface"

????.color = "buttontext"

????

????.cursor = "default"

???End With

??End If

?End Sub

?

?

?

?'===功能:?回调函数=====================================

?'===参数:?Key????关键字,可能是节点的关键字,也可能是菜单的关键字

?'???EventKey??事件关键字

?'===返回:?无

?Function CallBack(ByVal Key,ByVal EventKey)

?

??On Error Resume Next

??

??Select Case Ucase(EventKey)

???Case UCase("onClick")

????Me.SelectedNode = Me.Nodes(Key)

????TreeView_onClick Me.Name,Me.Nodes(Key)

????

???Case UCase("Menu_OnClick")

????TreeView_PopupMenu_onClick Me.Name,Key,lMenuNode

????

??End Select

??Err.Clear

?End Function

?'================================================================

End Class

?

'=============================================================

'===结点的类===================================================

Class Node

?Public parentObject??'该节点归属的TreeView对象

?Public Key????'层的关键字

?Private lText???'显示的文本

?Public Property Get Text()

??Text = lText

?End Property

?Public Property Let Text(ByVal vNewValue)

??lText = vNewValue

??'===设置文字

??Dim objNode

??Set objNode = document.getElementById(me.Key)

??If Not objNode Is Nothing Then

???objNode.rows(0).cells(Me.Level+2).firstChild.innerHTML = vNewValue

??End If

?End Property

?

?Private lHyperLink

?Public Property Get HyperLink()

??HyperLink = lHyperLink

?End Property

?Public Property Let HyperLink(ByVal vNewValue)

??lHyperLink = vNewValue

??Dim objNode

??Set objNode = document.getElementById(me.Key)

??If Not objNode Is Nothing Then

???objNode.rows(0).cells(Me.Level+2).firstChild.href = vNewValue

??End If

?End Property

?

??

?Public Index???'索引

?Public Level???'层次,根节点层次为0

?'Public HyperLink??'联接的地址

?Public ParentNode??'父节点

?Public PreviousNode??'前一个兄弟节点

?Public NextNode???'下一个兄弟节点

?Public ChildrenCount?'子节点个数

?Public NodeIndex??'索引,每一级用两位(26个大写字母)表示,共有26*26=676个节点

?Public ChildrenNodes?'子节点集合,从零开始

?Public AddType???'节点添加类型

?Public Flag????'附加标记,主要用于给用户在事件中扩展使用

?

?Private lImage????'图标

?Private lDisplayStatus??'显示状态??0-未显示,1-显示

?Private lExpandStatus??'展开状态??0-未展开,1-展开

?Private lFirstDisplay??'是否是第一次显示

?

?Private Sub Class_Initialize()

??Set parentObject = Nothing

??Key = ""

??lText = ""

??Index = 0

??Level = 0

??HyperLink = ""

??Set ParentNode = Nothing

??Set PreviousNode = Nothing

??Set NextNode = Nothing

??Redim ChildrenNodes(0)

??Set ChildrenNodes(0) = Nothing

??ChildrenCount = 0

??NodeIndex = ""

??Image = ""

??lExpandStatus = 0

??lDisplayStatus = 0

??lFirstDisplay = True

??

??AddType = "1"??'默认为添加子节点

??Flag = ""

?End Sub

?

?Public Function Display()

??dim tabTreeView,udtTreeView

??Set tabTreeView = Document.getElementById("tabTreeView")

??Set udtTreeView = Me.parentObject

??Dim objNode

??dim objTab,objTR,objTD

??dim i

??Set objNode = Document.getElementById(Me.Key)

??If objNode Is Nothing Then

??

???'===检测节点的添加类型

???If Me.AddType = 1 Then

????If Me.ParentNode.NextNode Is Nothing Then

?????If Me.PreviousNode Is Nothing Then

??????i = Document.getElementById(Me.ParentNode.Key).parentElement.parentElement.rowIndex + 1

?????Else

??????Set objNode = Me.PreviousNode

??????Do Until objNode.ChildrenCount = 0

???????Set objNode = objNode.Children(objNode.ChildrenCount)

??????Loop

??????i = Document.getElementById(objNode.Key).parentElement.parentElement.rowIndex + 1

?????End If

????Else

?????i = Document.getElementById(Me.ParentNode.NextNode.Key).parentElement.parentElement.rowIndex

????End If

???ElseIf Me.AddType = 2 then

????i = Document.getElementById(Me.NextNode.Key).parentElement.parentElement.rowIndex

???ElseIf Me.AddType = 3 Then

????If Me.NextNode Is Nothing Then

?????Set objNode = Me.PreviousNode

?????Do Until objNode.ChildrenCount = 0

??????Set objNode = objNode.Children(objNode.ChildrenCount)

?????loop

?????i = Document.getElementById(objNode.Key).parentElement.parentElement.rowIndex + 1

????Else

?????i = Document.getElementById(Me.NextNode.Key).parentElement.parentElement.rowIndex

????End If

???Else

????i = tabTreeView.rows.length

???End If

???Set objTR=tabTreeView.insertRow(i)

???Set objTD=objTR.insertCell()

???objTD.innerHTML = ""

???

???Set objTab = Document.getElementById(Me.Key)

???objTab.border = "0"

???objTab.Cellpadding = "0"

???objTab.CellSpacing = "0"

???

???Set objTR = objTab.insertRow()

???

???For i = 1 To Me.Level

????Set objTD = objTR.insertCell()

????objTD.innerHTML = "

"

???Next

???

???Set objTD = objTR.insertCell()

???

???Dim strImg

???If Me.parentObject.UseConnectLine Then

????strImg = "Lplus.gif"

???Else

????strImg = "Rplus.gif"

???End If

???objTD.innerHTML = "

"

???

???objTD.Height = 15

???Set objTD = objTR.insertCell()

???if Me.Image = "" Then

????objTD.innerHTML = "

"

???Else

????objTD.innerHTML = "

"

???End If

???Set objTD = objTR.insertCell()

???objTD.NoWrap = "1"????'不换行

???'objTD.height = "25"

???If Me.HyperLink = "" Then

????objTD.innerHTML = "" & Me.Text & ""

???Else

????objTD.innerHTML = "" & Me.Text & ""

???End If

???

??End If

??

??

?End Function

?

?'===孩子节点的集合=============================================================

?Public Function Children(ByVal Index)

??dim i

??Set Children = Nothing

??Index = Trim(Index)

??If IsNumeric(index) = False Then

???For i=0 to Ubound(ChildrenNodes)

????If UCase(ChildrenNodes(i).Key) = UCase(Index) Then

?????Set Children = ChildrenNodes(i)

?????Exit Function

????End If

???Next

??Else

???If Cint(index) ChildrenCount Then

????Exit Function

???Else

????Set Children = ChildrenNodes(CInt(index) - 1)

???End If

??End If

?End Function

?'==============================================================================

?

?'===添加一个子节点

?Public Function AddChild(objNode)

??Redim Preserve ChildrenNodes(ChildrenCount)

??Set ChildrenNodes(ChildrenCount) = objNode

??ChildrenCount = ChildrenCount + 1

?End Function

?

?'===展开状态

?Public Property Get ExpandStatus()

??ExpandStatus = lExpandStatus

?End Property

?Public Property Let ExpandStatus(ByVal vNewValue)

??Dim PlusValue

??If Me.ParentNode Is Nothing Or Not Me.parentObject.UseConnectLine Then

???If Me.ChildrenCount 0 Then

????PlusValue = "R"

???Else

????PlusValue = "Blank"

???End If

??Else

???If Me.NextNode Is Nothing Then

????PlusValue = "L"

???Else

????PlusValue = "T"

???End If

??End If

??

??If vNewValue = 0 Then

???If me.ChildrenCount 0 Or lFirstDisplay = True Then

????PlusValue = PlusValue & "plus"

???End IF

??ElseIf vNewValue = 1 Then

???If Me.ChildrenCount 0 Then

????PlusValue = PlusValue & "minus"

???End If

???lFirstDisplay = False

??End If

??

??lExpandStatus = vNewValue

??Document.getElementById("plus" & Me.Key).src = Me.ParentObject.ImagePath & PlusValue & ".gif"?

?End Property

?

?

?'===显示状态

?Public Property Get DisplayStatus()

??DisplayStatus = lDisplayStatus

?End Property

?Public Property Let DisplayStatus(ByVal vNewValue)

??If Not Me.parentNode Is Nothing Then

???If CBool(vNewValue) And Not CBool(Me.parentNode.ExpandStatus) Then

????Exit Property

???End If

??End If

??

??

??lDisplayStatus = vNewValue

??

??Dim obj

??Set obj = Document.getElementById(Me.Key)

??If Not obj Is Nothing Then

???Set obj = obj.parentElement.parentElement

???If CBool(vNewValue) Then

????obj.style.display = ""

???Else

????obj.style.display = "none"

???End IF

??End If

??Set obj = Nothing

?End Property

?

?'===节点图标

?Public Property Get Image()??'带目录的文件名

??Image = lImage

?End Property

?Public Property Let Image(ByVal vNewValue)

??lImage = vNewValue

??If NOT Document.getElementById(Me.Key) Is Nothing Then

???Document.getElementById(Me.Key).rows(0).cells(Me.Level+1).FirstChild.src = vNewValue

??End IF

?End Property

?

End Class

?

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有