C
cronusf
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.
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.