Draw rectangle on picturebox (moving with mouse)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Red Head
    New Member
    • Feb 2008
    • 5

    Draw rectangle on picturebox (moving with mouse)

    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_Mou seMove(object sender, MouseEventArgs e)
    {
    Point startPoint = ((Control)sende r).PointToScree n(new Point(e.X, e.Y));


    ControlPaint.Dr awReversibleFra me(r, this.BackColor, FrameStyle.Dash ed);

    r = new Rectangle(start Point.X, startPoint.Y, 100, 200);
    ControlPaint.Dr awReversibleFra me(r, this.BackColor, FrameStyle.Dash ed);
    }
    [/PHP]
Working...