vbscript版的TreeView,也就是树[2]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 efei 的 blog

?????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 <= me.nodescount then
????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======================================================
?

本文关键:vbscript版的TreeView,也就是树
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top