treeview 遍历搜索 定位目标

    Private Function Findnode(ByVal treelist As TreeNodeCollection)
        If treelist Is Nothing Then
            Return ""
        End If
        Dim nodex As TreeNode
        For Each nodex In treelist
            If nodex.Text = citystr Then
                nodex.EnsureVisible()
                nodex.Checked = True
                Me.DreamsTView1.SelectedNode = nodex
                Me.DreamsTView1.Focus()
            Else
                Findnode(nodex.Nodes)
            End If
        Next
    End Function

用下以方法使用

        cmd = New OleDbCommand(strcity5, conn)
        Try
            If conn.State = ConnectionState.Closed Then
                conn.Open()
            End If
        Catch ex As Exception

        End Try
        read = cmd.ExecuteReader()
        If read.Read() Then
            'TraverseNode(DreamsTView1.Nodes)
            Findnode(DreamsTView1.Nodes)
        End If
        read.Close()

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页