Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing DrawRectangle in Windows Forms

I am drawing a rectangle, sleeping for a few milliseconds--then I want to clear the rectangle, but I can't figure out how. (The rectangle is sitting over a graphic so I can't simply cover it up with another rectangle)

                graphics.DrawRectangle(p, innerRectangle)
                System.Threading.Thread.Sleep(75)
                Next I want to clear the rectange...
like image 208
Jeff Avatar asked Jun 11 '09 19:06

Jeff


People also ask

How do you clear a rectangle in C#?

simply remove the Mouseup event then. Though you would want to toss the rectangle at that point into a variable so you can keep it. Also as I said the drawing is not persistant, meaning that if you minimize the form or cover it with another window, it will not redraw the rectangle.

How do you draw shapes in Windows Forms?

You can draw filled shapes by selecting which shape you want, click picturebox and drag mouse to get which size you want. But THIS can happens when I drag. When I use refresh(); , shapes -which previously drawn- deletes itself.


1 Answers

You need to redraw the graphic (or at least the part of it under the rectangle). If this is a picture box or something similar, use Invaldiate() to force a repaint.

like image 69
Jon B Avatar answered Sep 26 '22 21:09

Jon B