user562854
user562854

Reputation:

PictureBox slow loading on Form.Show()

I have Form1 which contains some pictureboxes with png images. When I hide Form1, and then show it again using Form1.Show(), i see a white box instead of the png image for less than 1 second...but I still can see it. It's strange that other larger images in the same Form1 are loading instantly...while this one needs some miliseconds to load. Can this be fixed by caching the images in memory or..?!

Click to view a screenshot

Upvotes: 1

Views: 1446

Answers (1)

Seffix
Seffix

Reputation: 1049

Try and use SuspendLayout() & ResumeLayout(false) so the form won't change it's layout until the images are loaded. call

    this.SuspendLayout();

before Show() and set boolians in the picturebox.LoadCompleted events to true, and call

    this.ResumeLayout(false);

when all of them are true.

Upvotes: 1

Related Questions