views:

98

answers:

1

I have a UserControl with a few buttons on it. I want to override OnPaint and paint some other stuff on the control.

So I override OnPaint.

Whenever OnPaint gets called the ClipRectangle is always {0,0,0,0} and so nothing I do gets drawn on the control.

What am I doing wrong?

+1  A: 

Ok, Ive sussed it now. Its a bit silly. I had a TableLayoutPanel that was docked to the control. That seems to clip out all the areas that we can paint on.

I created a new control that derives from TableLayoutPanel and used this control instead. Its OnPaint gets the full clip rect.

However, that wasnt any use anyway... It seems I have misunderstood how Windows painting works. I thought I would be able to paint directly over the top of my controls, but this isnt the case. The controls get placed on top of my painting.

Gonna have to mess about with panels to get this working I reckon..

Mongus Pong