James,
The way that you are going about it is wrong. What you want to do is
override the OnPaint method so that it will draw your shape, or, clear the
panel, based on state that you set in your form.
For example, I would have a boolean field indicating whether or not to
paint the shape or not.
Then, in your OnPaint method (after you call the base method
implementation), you would paint your shape.
Also, you might want to use the using statement when constructing the
Brush. If you don't, then you will leak resources.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"James" <c_********@yahoo.co.uk> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hello,
I'm drawing to the window and want to then clear it to the standard
background colour.
However I get errors when trying either of the following:
Graphics g = CreateGraphics();
g.Clear(Parent.BackColor);
g.FillRectangle(new SolidBrush(Parent.BackColor), 0, 0, 600, 600);
Can anyone please help?
James Round