Thread: How to populate image tree faster.

  1. #1
    Registered User verbity's Avatar
    Join Date
    Nov 2006

    How to populate image tree faster.

    Hi...could someone help me figure out how load my thumbnails either faster....or just in the background so I can still use my UI? I have a form that loads/imports photos and it takes about 5 to 6 seconds to load thumbnails of just average sized photos. I'm using a progress bar which is just sitting in the middle of my UI until the thumbnails load. Can someone help out? Here is my populateTree function: (I'm using a e.Graphics.DrawImage() in my Utilities.cs to draw the actual thumbnail)

    private void PopulateTree()
                string[] albumList = Directory.GetFiles(_directoryCurrentUser, "*" + ".album");
                treeView_Albums.Nodes.Clear(); //Clears nodes so they can be added again
                int totalAlbums = albumList.Count();
                //Loop through each found file and add it to tree. Set its path and show the file name
                for (int i = 0; i < totalAlbums; i++)
                    var node = new TreeNode
                                       Name = albumList[i],
                                       Text =
                                           Utilities.getNameFromPath(albumList[i]) +
                                       ImageIndex = 0
                    if (node.Name == _albumData.FilePath) //Highlight if album node is open
                        node.BackColor = Color.LightGray;
    Using VSPro2010
    Thanks in advance....

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    Before populating the tree, call BeginUpdate Method. When you're done populating it, call EndUpdate Method.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Populate An Array With Numbers
    By mcertini in forum C++ Programming
    Replies: 6
    Last Post: 01-08-2011, 11:35 AM
  2. populate an array struct
    By flipguy_ph in forum C Programming
    Replies: 10
    Last Post: 04-17-2009, 04:07 PM
  3. FOR loop to populate a 2D array
    By Swerve in forum C++ Programming
    Replies: 7
    Last Post: 03-05-2008, 10:45 AM
  4. Wish to populate a 2D array using pointers
    By hamsteroid in forum C Programming
    Replies: 14
    Last Post: 10-24-2007, 10:28 AM
  5. help populate the irc channel
    By chrismiceli in forum A Brief History of
    Replies: 19
    Last Post: 09-22-2003, 06:23 PM