tags:

views:

34

answers:

1

Hi. I have about 30 picture boxes in my form. all pictures are the same. how can i save memory in this case? for example define a picture and bind it to all picture boxes. to increase application size and Reduce memory usage. thanks.

+4  A: 

You can create a single Image instance in your code and display the same instance in every PictureBox.


Writing a game with PictureBoxes for every sprite is an extremely bad idea.
You should draw your game by hand by handling the Paint event of a double-buffered control.

For more information, see here.

SLaks
thanks you.i read picture from a file.how can i do it?
shaahin
Call `new Bitmap(path)` or `Image.FromFile(path)`.
SLaks
So.I Designed My board and NUT in photoshop and saved as PNG.i am creating Backgammon.I cant Design that nuts and board in .net .how can i optimize?what is correct way?
shaahin
You should draw all of the PNG images manually in a single Paint event.
SLaks