tags:

views:

421

answers:

2

I think you can do GDI+ drawing in just about any window in a .net windows forms project, but what do you recommend as the best built-in control for containing custom drawing? I'm going to be drawing my own x-y plots, text and images. I could use a Panel, UserControl, etc.

+4  A: 

If you're just drawing the control and not hosting children, then derive from Control - VS will make you a suitable class (it calls this a 'Custom Control') with the OnDraw handler already stubbed in.

If you're hosting other controls within your control, then derive from UserControl, (VS calls this a 'User Control' and you'll get support for VS designer, so you can drag around other controls on top.

For simple non-scrolling charting I would derive from Control.

Will Dean
+2  A: 

Do your GDI+ drawing in an offscreen bitmap surface, and then blit it to whatever control you need.

Your controls Paint method only needs to copy the surface to itself.

FlySwat