CloneXpert
Junior Poster in Training
64 posts since Aug 2010
Reputation Points: 30
Solved Threads: 19
When are you calling that code?
Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
The Form_Paint event is called every time part of the UI is repainted, every time it fires your picturebox grows, eventually getting so large it is too large for the programs allocated memory.
If you want to resize your controls according to the size of the form then you need to adjust it relative to the form; you could use a similar approach to the one used in webdesign and calculate the height and width of controls as a percentage of their container:
Panel1.Width = Form1.Width * 0.5 //set width to 50% of form
Button1.Width = Panel1.Width * 0.2 //button is 20% of the panel it is placed in
//etc
If you want to alter them according to a fixed scale then you need to apply the scale ONCE when the form first loads, rather than every time it is refreshed.
Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246