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
2008-10-31 21:21:09
+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
2008-10-31 21:23:10