隐藏树列表中的文件夹名称

时间:2017-07-27 02:44:48

标签: vb.net devexpress

如何在树状列表中隐藏特定的名称文件夹?我有这样的树列表

enter image description here

我希望隐藏文件夹名称New folderpdf。我是从Load Data Dir做出来的。我通过放置if

在代码中稍微调整一下
Dim rootfolder As String = "C:\\FFOutput"

Private Sub TreeList1_VirtualTreeGetCellValue(ByVal sender As Object, ByVal e As DevExpress.XtraTreeList.VirtualTreeGetCellValueInfo) Handles TreeList1.VirtualTreeGetCellValue
    Dim di As New DirectoryInfo(CStr(e.Node))
    If di.Name <> "New folder" Then
        If e.Column Is TreeListColumn1 Then
            e.CellData = di.Name
        End If
        If e.Column Is TreeListColumn2 Then
            e.CellData = e.Node.ToString

        End If
        If e.Column Is TreeListColumn3 Then
            If IsFile(di) Then
                e.CellData = New FileInfo(CStr(e.Node)).Extension
            Else
                e.CellData = Nothing
            End If
        End If
    End If
End Sub

Private Sub TreeList1_VirtualTreeGetChildNodes(ByVal sender As Object,
ByVal e As DevExpress.XtraTreeList.VirtualTreeGetChildNodesInfo) _
Handles TreeList1.VirtualTreeGetChildNodes
    If loadDrives = False Then            
        Dim root As String() = Directory.GetDirectories(rootfolder)
        e.Children = root
        loadDrives = True
    Else
        Try
            Dim di As New DirectoryInfo(CStr(e.Node))
            If di.Name <> "New folder" Then
                Dim path As String = CStr(e.Node)
                If Directory.Exists(path) Then
                    Dim dirs As String() = Directory.GetDirectories(path)
                    Dim files As String() = Directory.GetFiles(path)
                    Dim arr(dirs.Length + files.Length) As String
                    dirs.CopyTo(arr, 0)
                    files.CopyTo(arr, dirs.Length)
                    e.Children = arr                        
                Else
                    e.Children = New Object() {}
                End If
            End If
        Catch

        End Try
    End If
End Sub

它就像这样

enter image description here

0 个答案:

没有答案