List Folders as all CAPS in Treeview? 
Author Message
 List Folders as all CAPS in Treeview?

How can you have all Folders in a Treeview in capitals?  As you know, TV will
list folder names with case as they were created (all caps, all lower case,
and a mixture).  I want to have them all as upper case just to have them
viewed identically.

In something like a Listview, etc. you can use "UCase()" to do this.  But I'm
not sure on how to for Treeview (if you can at all).

The example code which I'm working from is:

  Protected Overrides Sub OnBeforeExpand(ByVal tvcea As
TreeViewCancelEventArgs)
    MyBase.OnBeforeExpand(tvcea)

    ' For performance reasons and to avoid TreeView "flickering" during an
    ' large node update, it is best to wrap the update code in BeginUpdate.
    ' EndUpdate statements
    Me.BeginUpdate()

    Dim tn As TreeNode
    ' Add child nodes for each child node in the node clicked by the user
    ' For performance reasons each node in the DirectoryTreeView
    ' contains only the next level of child nodes in order to display the
    ' + sign to indicate whether the user can expand the node. So when
    ' the user expands a node, in order for the + sign to be appropriately
    ' displayed for the next level of child nodes, *their* child nodes have
    ' to be added
    For Each tn In tvcea.Node.Nodes
      AddDirectories(tn)
    Next tn

    Me.EndUpdate()
  End Sub

  ' This subroutine is used to add a child node for every directory under its
  ' parent node, which is passed as an argument. See further comments in the
  ' OnBeforeExpand event handler
  Sub AddDirectories(ByVal tn As TreeNode)
    tn.Nodes.Clear()

    Dim strPath As String = tn.FullPath
    Dim diDirectory As New DirectoryInfo(strPath)
    Dim adiDirectories() As DirectoryInfo

    Try
      ' Get an array of all sub-directories as DirectoryInfo objects
      adiDirectories = diDirectory.GetDirectories()
    Catch exp As Exception
      Exit Sub
    End Try

    Dim di As DirectoryInfo
    For Each di In adiDirectories
      ' Create a child node for every sub-directory, passing in the directory
      ' name and the images its node will use
      Dim tnDir As New TreeNode(di.Name, 1, 2)
      ' Add the new child node to the parent node
      tn.Nodes.Add(tnDir)
    Next
  End Sub

Thanks...

Bruce



Thu, 23 Jun 2005 05:24:51 GMT  
 List Folders as all CAPS in Treeview?
Before adding your values to the treeview change them to ucase.  Not tested
but I think you could place it here:

Quote:
>       Dim tnDir As New TreeNode(UCASE(di.Name), 1, 2)
>       ' Add the new child node to the parent node
>       tn.Nodes.Add(tnDir)
>     Next



Quote:
> How can you have all Folders in a Treeview in capitals?  As you know, TV
will
> list folder names with case as they were created (all caps, all lower
case,
> and a mixture).  I want to have them all as upper case just to have them
> viewed identically.

> In something like a Listview, etc. you can use "UCase()" to do this.  But
I'm
> not sure on how to for Treeview (if you can at all).

> The example code which I'm working from is:

>   Protected Overrides Sub OnBeforeExpand(ByVal tvcea As
> TreeViewCancelEventArgs)
>     MyBase.OnBeforeExpand(tvcea)

>     ' For performance reasons and to avoid TreeView "flickering" during an
>     ' large node update, it is best to wrap the update code in
BeginUpdate.
>     ' EndUpdate statements
>     Me.BeginUpdate()

>     Dim tn As TreeNode
>     ' Add child nodes for each child node in the node clicked by the user
>     ' For performance reasons each node in the DirectoryTreeView
>     ' contains only the next level of child nodes in order to display the
>     ' + sign to indicate whether the user can expand the node. So when
>     ' the user expands a node, in order for the + sign to be appropriately
>     ' displayed for the next level of child nodes, *their* child nodes
have
>     ' to be added
>     For Each tn In tvcea.Node.Nodes
>       AddDirectories(tn)
>     Next tn

>     Me.EndUpdate()
>   End Sub

>   ' This subroutine is used to add a child node for every directory under
its
>   ' parent node, which is passed as an argument. See further comments in
the
>   ' OnBeforeExpand event handler
>   Sub AddDirectories(ByVal tn As TreeNode)
>     tn.Nodes.Clear()

>     Dim strPath As String = tn.FullPath
>     Dim diDirectory As New DirectoryInfo(strPath)
>     Dim adiDirectories() As DirectoryInfo

>     Try
>       ' Get an array of all sub-directories as DirectoryInfo objects
>       adiDirectories = diDirectory.GetDirectories()
>     Catch exp As Exception
>       Exit Sub
>     End Try

>     Dim di As DirectoryInfo
>     For Each di In adiDirectories
>       ' Create a child node for every sub-directory, passing in the
directory
>       ' name and the images its node will use
>       Dim tnDir As New TreeNode(di.Name, 1, 2)
>       ' Add the new child node to the parent node
>       tn.Nodes.Add(tnDir)
>     Next
>   End Sub

> Thanks...

> Bruce



Thu, 23 Jun 2005 08:41:53 GMT  
 List Folders as all CAPS in Treeview?

Quote:
>Before adding your values to the treeview change them to ucase.  Not tested
>but I think you could place it here:

>>       Dim tnDir As New TreeNode(UCASE(di.Name), 1, 2)
>>       ' Add the new child node to the parent node
>>       tn.Nodes.Add(tnDir)
>>     Next

Nutz... kind was not hoping for that answer (suspected it though)... thanks!
Bruce


Fri, 24 Jun 2005 05:41:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Treeview control changing the picture to open folder/close folder

2. can i set the folder in the outlook folder list

3. Change of focus from the item list pane to the folder list pane in an explorer

4. TreeView - Simulating dropping a file into a folder

5. treeview folder icons

6. Using TreeView for File Folders - Help

7. treeview??? filled whit folders, and file

8. Is Folder Node in TreeView?

9. Drag and drop from folder to TreeView control?

10. Explorer-style TreeView Folders of HD

11. Folder TreeView

12. Treeview displaying folders / files

 

 
Powered by phpBB® Forum Software