GDI Drawing on usercontrol causes excessive tearing
Hey,
I had a form that generated a simple graph that you can manipulate, all done through GDI and it works great, although i have double buffering on the form.
Now im having to change alot of these forms into usercontrols so that i can house them all within tab pages in another form...
Anyway now ive put them into the tab control and there is alot of tearing whenever i change the values (thats when it refreshes), the containers used to be:
Form - GDI Drawing
Now its
Form
|
| - TabPanelControl
| |
| | - TabPageControl
| | |
| | | - CustomControl - GDI Drawing
So im wondering if its down to it being placed in another control, ive set the form to double buffered, anyway if anyone has any advice let me know!
Re: GDI Drawing on usercontrol causes excessive tearing
Just incase anyone else has this problem i was able to solve this problem by adding this to the constructor of my control:
Code:
this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
this.UpdateStyles();
Re: GDI Drawing on usercontrol causes excessive tearing
I didn't really know what you meant by 'tearing', but I guess now that you meant flashing. It was happening because your grid was no longer double buffered once you removed it as a child of the form. Setting a form to double buffered means that its graphics object will be double buffered, it does not propagate down to all the children.