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()

阅读更多
个人分类: C# VB.NET
上一篇获取不同版本的DataRow
下一篇C#中对注册表的操作 读写注册表方法
想对作者说点什么? 我来说一句

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

关闭
关闭
关闭