drawing custom control



In my control's constructor I set:

SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);

My reference book, "Programming Windows Forms" by Charles Petzold says
this means that all painting logic is performed in the OnPaint
method.

I override OnPaint and do my custom drawing code. However, I noticed
that if I add child controls to my UserControl, those are painted
automatically. Can someone explain how the drawing of child controls
works?

This behavior is fine--I'd rather them automatically be drawn then
have to do it myself, I just wasn't expecting it since I figured I had
to do all the drawing for my custom control.



.



Relevant Pages

  • RE: drawing custom control
    ... this means that all painting logic is performed in the OnPaint ... I override OnPaint and do my custom drawing code. ... Can someone explain how the drawing of child controls ...
    (microsoft.public.dotnet.framework.windowsforms)
  • How to draw over controls?
    ... I want to draw some polygons on a panel, and hope the drawing can be over ... In Windows Form, I can create a real-transparent as the top-most canvas, ... then drawing on it will be over all other child controls; ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: When are Forms is Fully Drawn?
    ... You could override OnPaint, call the base and then at that point drawing is ... Chris Tacke ... Managed Code in the Embedded World ...
    (microsoft.public.pocketpc.developer)
  • Re: Overriding Button Class Text.set and OnPaint
    ... the drawing seems to be taking place in the set method. ... try to override OnPaint and VS never even stops on my OnPaint ... Graphics object from the control. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Dissable Label Font Color...
    ... > How can I change the font color of a dissabled label control? ... You could override OnPaint in a derived class and handle drawing the text ... string in your override, thus allowing you to use whatever color you wanted ...
    (microsoft.public.dotnet.languages.csharp)