How to make a custom panel control that can contain other controls?

  • Thread starter Thread starter news.austin.rr.com
  • Start date Start date
N

news.austin.rr.com

Hi,

I want to make a custom Panel control by inheriting from the Control class.
This will allow me to control painting in the OnPaint handler. If I inherit
from the Panel class I cant get it to paint the way i want to, although the
OnPaint handler does execute. So how can i add the parent container
behaviour to my custom control that inherits from the Control class. I want
to be able to place other controls in it like the standard Panel control...


Thanks
 
I do not see any other ways than derive your class from Panel (or
System.Windows.Forms.ContainerControl). You can not CreateGraphics for
such control but you can use existent PaintEventArgs.Graphics to draw
all what you want in the OnPaint/OnPaintBackground event.


Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
Back
Top