Question

I am creating an application using WinForms which will potentially have upwards of 100 different images/objects on screen. Is it better to use the Paint event on the form, or have 100 different pictureboxes?

Edit: After some testing, I switched my code to use the Paint event. Thanks for the help everyone!

Was it helpful?

Solution

You should handle the Paint event.
(and make sure to enable double-buffering)

Making large numbers of controls will lead to performance issues.
Also, painting everything yourself allows you to easily use more-complicated effects like transparency.

Alternatively, switch to WPF.

OTHER TIPS

I recommend to use the Paint event since it has better performance then the PictureBox and its compatible with older .NET, but PictureBox are also pretty useful to show images from resources like .JPEG files.

TIP: If you want to use the same image in multiple PictureBox controls, create a clone of the image for each PictureBox. Accessing the same image from multiple controls causes an exception to occur.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top