469,950 Members | 1,938 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Draw rectangle on picturebox (moving with mouse)


I've written some code to draw a rectangle on a picture box when the user moves the mouse.
(the previous rectangle is cleared)
This works fine but the very first rectangle is not removed from the screen.

here is my code

private Rectangle r = new Rectangle(new Point(0,0), new Size(0,0));

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
Point startPoint = ((Control)sender).PointToScreen(new Point(e.X, e.Y));

ControlPaint.DrawReversibleFrame(r, this.BackColor, FrameStyle.Dashed);

r = new Rectangle(startPoint.X, startPoint.Y, 100, 200);
ControlPaint.DrawReversibleFrame(r, this.BackColor, FrameStyle.Dashed);
Feb 27 '08 #1
0 1768

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Brad Shook | last post: by
1 post views Thread by nicolus | last post: by
10 posts views Thread by kimiraikkonen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.