转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
vbscript版的TreeView,也就是树         ★★★★

vbscript版的TreeView,也就是树

作者:闵涛 文章来源:闵涛的学习笔记 点击数:2325 更新时间:2009/4/23 15:43:40
) = 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) <= Ubound(ArrImage,2) AND 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.number<>0 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.Nod

上一页  [1] [2] [3]  下一页


[常用软件]TreeView 控件应用详解  [VB.NET程序]Henry手记-VB.NET中动态加载Treeview节点(二)
[VB.NET程序]Henry手记-VB.NET中动态加载Treeview节点(一)  [Delphi程序]Delphi中为TreeView添加单选和复选框
[Delphi程序]Object TreeView简要说明  [Delphi程序]Delphi下Treeview控件基于节点编号的访问
[VB.NET程序]将listview中显示出来的记录拖到treeview中去  [VB.NET程序]TreeView 控件树状控件的填充VB以及 VS.NET C#源代…
[VB.NET程序]Treeview 控件的使用方法  [Web开发]在ASP.NET中使用Treeview控件和XML
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台