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

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
 
S

Sergey Bogdanov

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top