
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