Hi,
I'm trying to make an ImageListBox kind of control that will display large numbers of thumbnails, like the one that Picasa uses.
This is my design:
I have a FlowLayoutPanel that is populated with a LOT of UserControls, for example 4,000. Each UserControl is assigned a delegate for the Paint event. When the Paint event is called, it checks a memory cache for the thumbnail and if the image is not in cache, it retrieves it from the disk.
I have two problems that I'm trying to solve:
It seems that WinForms will trigger a Paint event even if the UserControl is not in view. Only 10 or so controls are in fact in view, the rest are not in view (the FlowLayoutPanel.AutoScroll is set to true). As a result, it tries to retrieve thumbnails for ALL the images and that takes a long time...
Adding the UserControls to the FlowLayoutPanel takes a somewhat long time - about 2-3 seconds. I can live with it but I'm wondering if there is a better way to do it than:
UserControl[] boxes = new UserControl[N]; // populate array panel.SuspendLayout(); panel.Controls.AddRange(boxes); panel.ResumeLayout();
Any help is very much appreciated, thank you.