Form Canvas

D

DaveL

Is Below the approiate way to clear a Canvas of a windows canvas
or is there a better way, what im doing is painting pictures of
different sizes based on user selection on size


Graphics g = CreateGraphics();
g.FillRectangle(new SolidBrush(Color.White), this.ClientRectangle);

//draw text over each picture
//draw picture loop here


thanks DaveL
 
J

Jeff Johnson

Is Below the approiate way to clear a Canvas of a windows canvas
or is there a better way, what im doing is painting pictures of
different sizes based on user selection on size


Graphics g = CreateGraphics();
g.FillRectangle(new SolidBrush(Color.White), this.ClientRectangle);

Without looking at the help files (so I might be wrong), I seem to recall
there is a Graphics.Clear() method.
 
D

DaveL

Thank you, i'll make the changes

DaveL

Peter Duniho said:
Jeff is correct, there is a Graphics.Clear() method. You don't even need
to create a brush to use it.

However, you shouldn't need to call CreateGraphics() to draw anything.
The only place you ought to be drawing is in the OnPaint() method (or
possibly an event handler for the Paint event, depending on your
implementation), and there a Graphics instance is passed to you in the
PaintEventArgs class.

So if that code is actually similar to what you're using in your program,
you've got a broader design mistake there.

Pete
 

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