简体   繁体   中英

How to speed up picturebox graphics

I have a program that takes some information from databases and represents it graphically via pictureboxes in a form. Each piece of data is a differently colored picturebox and it basically looks like defragmenter.

For example

显示示例

The program uses a loop to go through specific chunks of the database and represents it graphically. The problem is, for large amounts of data/pictureboxes, it takes quite some time to draw them all (eg >20 seconds for few thousand, and even crashes a program for over 10,000 data pieces).

Is there a way to make a program draw those graphics in less then a second or close to it?

You can draw them yourself. Instead of having a lots of picture boxes, just use the Paint event of the control where you want to show them.

The event handler will get a Graphics object for the control that you can use to draw the boxes. You can use the FillRectangle method to draw the boxes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM