3 Replies - 589 Views - Last Post: 16 February 2012 - 03:02 PM Rate Topic: -----

#1 TechnoBear  Icon User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 222
  • Joined: 02-November 11

TreeView Display Folders in correct order

Posted 16 February 2012 - 12:45 PM

I have used the TreeView and populated the list using the following code:

        m_strStation = cboStation.SelectedItem

        For Each strDir As IO.DirectoryInfo In New IO.DirectoryInfo(m_strPath & m_strStation).GetDirectories()
            trvFolders.Nodes.Add(strDir.Name)
        Next


The TreeView populates and every folder is visible, however the folder names consist of:

Place #. Name

the problem I am having is that the number range is 1 - 16 and the order in which the folders are being displayed is 1, 10, 11, ..., 15, 16, 2, 3, ..., 8, 9

I am looking for the folders to be listed in true numerical order e.g. 1, 2, 3, ..., 14, 15, 16

How would I get this to be done properly

Is This A Good Question/Topic? 0
  • +

Replies To: TreeView Display Folders in correct order

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,658
  • Joined: 02-June 10

Re: TreeView Display Folders in correct order

Posted 16 February 2012 - 02:15 PM

I'd probably make a sorteddictionary<string,string> Where the key is the actual string and the value is the string padded to 4 places.


Place 1. Name, Place 0001.Name
Place 2. Name, Place 0002.Name

and so on.

You alphabetize on the padded key string but display based on the value.
Was This Post Helpful? 0
  • +
  • -

#3 TechnoBear  Icon User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 222
  • Joined: 02-November 11

Re: TreeView Display Folders in correct order

Posted 16 February 2012 - 02:56 PM

maybe I was unclear The name of the folder it is trying to bring up is for example: "1. FCC Authorizations"
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,658
  • Joined: 02-June 10

Re: TreeView Display Folders in correct order

Posted 16 February 2012 - 03:02 PM

Ok. Whatever. It doesn't change the concept.

Pad the numbering so it will alphabetize correctly.
Stick the padded name and the real name in a sorteddictionary
view by value.

This i why I always just name my folders right in the first place

001. Windows OS
002. Updates
003. Drivers
004. Patches
005. Applications
006. Get a life
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1