扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:bean 来源:博客园 2007年11月9日
关键字:
Private Sub FillTree(ByRef pnode As myTreeNode, Optional ByVal filter As String = "") mDataView.RowFilter = filter Dim i As Integer, icol As Integer Dim newnode As myTreeNode RemoveHandler cm.PositionChanged, AddressOf cm_PositionChanged Me.BeginUpdate() For i = 0 To mDataView.Count() - 1 newnode = New myTreeNode(GetDisplay(i), GetValue(i), GetPid(i), GetCPtr(i)) '当有子结点时,为这个结点添加一个空子结点 If newnode.CPtr Then Dim nullnode As New myTreeNode() nullnode.Value = NoExpandNodeValue newnode.Nodes.Add(nullnode) End If If pnode Is Nothing Then Me.Nodes.Clear() Me.Nodes.Add(newnode) Else pnode.Nodes.Add(newnode) End If Next Me.EndUpdate() mDataView.RowFilter = "" AddHandler cm.PositionChanged, AddressOf cm_PositionChanged End Sub |
Private Sub dbTreeView_BeforeExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles MyBase.BeforeExpand '当是新增结点引起BeforeExpand事件时,直接退出。 If ExpandWhenAddNode Then Exit Sub '在展开结点前更新子结点 Dim currentnode As myTreeNode = CType(e.Node, myTreeNode) With currentnode .Nodes.Clear() FillTree(currentnode, mPidMember & "= " & CInt(.Value)) End With End Sub |
Private Sub dbTreeView_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles MyBase.AfterSelect If e.Node Is Nothing Then Exit Sub '定位到position cm.Position = GetPosition(CType(e.Node, myTreeNode).Value) If AllowEdit Then oldNode = e.Node oldPos = cm.Position End If End Sub |
Public Sub cm_PositionChanged(ByVal sender As Object, ByVal e As System.EventArgs) If CType(Me.SelectedNode, myTreeNode).Value <> GetValue(cm.Position) Then Debug.WriteLine("Current node isn't correct point to currencymanager.position!") Me.SelectedNode = FindNodeByValue(GetValue(cm.Position), Me.Nodes) End If If AllowEdit Then If Me.SelectedNode Is Nothing AndAlso cm.Position = cm.Count - 1 Then '当新增记录时,新增树结点 If CType(cm.Current, DataRowView).IsNew Then Me.SelectedNode = AddNode(cm.Position) Exit Sub End If End If If Not oldNode Is Nothing Then If CType(oldNode, myTreeNode).Value = GetValue(oldPos) Then '更新老结点 oldNode.Text = GetDisplay(oldPos) Else End If End If End If End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者