Connecting Tech Pros Worldwide Forums | Help | Site Map

Draw rectangle on picturebox (moving with mouse)

Newbie
 
Join Date: Feb 2008
Posts: 5
#1: Feb 27 '08
Hello

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

[PHP]
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);
}
[/PHP]

Reply


Similar .NET Framework bytes