?
Solved

Resource Manager vs Resource File C#

Posted on 2011-03-19
4
Medium Priority
?
737 Views
Last Modified: 2012-05-11
I have a resource setup with a bunch of 16x16 PNG's that we use for images on a tree view.

We build this treeviews in code and we used to use an imagelist which gaves us trouble so we were adding the images like this:

treeNode.LeftImages.Add(gloabl::project.rsx16.phoneImage);

Now, on a large set of data (7K records, 3 nodes deep so that is 21K nodes) we would randomly get out of memory errors. Even on a dev machine with 8gig ram. So, I did a little digging and found the resourcemanager class in System.Resources, and tried this;

ResourceManager rm = new ResourceManager(resourceFile, etc);
treeNode.LeftImages.Add((Image)rm.GetObject("phoneImage");

I decided before I go further, let me ask, which way is right? Or should I before the loop that  populates the tree create an instance of the image? I want to enusre that ONE instance of the image exists, but also want to follow best practices.

Image phone = (Image)rm.GetObject etc;

treeNode.LefImages.Add(phone);
0
Comment
Question by:melegant99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
MlandaT earned 2000 total points
ID: 35386816
I generally find that working with the ImageList is a faster option for working with a large treeview. How about loading the resource images into the ImageList at runtime first? Then just configuring the treeview to use the imageList as normal.

21,000 nodes in a treeview also sounds like overkill... from teh perspective of usability. Does the user really need to have all 21,000 nodes loaded in one go into the tree? How about only adding the child nodes when the user expands a node (might be less responsive than preloading the child nodes, especially where there are many child nodes at the same level, but this results in less runtime memory usage... and even a lower startup time for the tree in the first place since it wont be loading 21,000 nodes)?
0
 

Author Comment

by:melegant99
ID: 35410968
Hi,
If I use an imagelist, does that mean all the nodes will point to one instance of the image in memory, or am I getting an image for every node?

Yes, the 21K is overkill. However it is 21K in a multiple of levels, at the root maybe there are 100 nodes.

Thanks for responding btw, this question sat out there a long time.
0
 
LVL 31

Expert Comment

by:MlandaT
ID: 35414599
ImageList yes. From what I understand, it uses handles and pointers internally so you wont have a copy of the image for each item.

21,000... yes... even if you put it in multiple levels. If you think of it from a usability point of view, it's really a lot for a tree...  I think :) ... I doubt any of your users will ever really need to go through all those items at any one time :)
0
 

Author Closing Comment

by:melegant99
ID: 35414762
Going to change to the tree to be more on demand.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question