tags:

views:

84

answers:

2
+1  A: 

Add following in New (after InitializeComponents):

this.SetStyle(ControlStyles.ResizeRedraw, true);

This is to ensure painting on resize.

There are few additional styles that you may try (AllPaintingInWmPaint, UserPaint...) but whether they should be set or not depends on your particular case and what exactly you want to do. In case that all painting is done by you in Paint event, I would set them.

Josip Medved
Josip. If I add this then the whole form seems to go very flickery when I begin resizing things...
Ian
You need to add them just for the panel.
ThePower
+3  A: 

I would suggest creating your own panel, derive it from panel and place the following in the constructor:

  this.SetStyle(ControlStyles.AllPaintingInWmPaint 
              | ControlStyles.OptimizedDoubleBuffer
              | ControlStyles.ResizeRedraw 
              | ControlStyles.DoubleBuffer 
              | ControlStyles.UserPaint
              , true);
ThePower
Fair enough. Works like a charm. I still don't quite understand why the original problem manifested itself though?
Ian
It's because when you are resizing, the paint event isn't getting fired. So you need to force it with the ResizeRedraw, the rest aren't compulsary but help out with improvement in their own little ways. The flickering of your form before was because you were setting the style for the form and not the panel. It's a fun world, the manual painting world!
ThePower