C#C
C#2y ago
CHΔNGΕ

drawing Rectangles in winforms c# help

Point shapestartP = new Point(0, 0);
 private void picBoxMain_MouseUp(object sender, MouseEventArgs e)
 {
     flagDraw = false;
     g = Graphics.FromImage(bm);



     if (flagDrawingTool == "Rectangle")
     {
         g.DrawRectangle(pen, shapestartP.X, shapestartP.Y,Math.Abs(e.Location.X - shapestartP.X ),Math.Abs(e.Location.Y - shapestartP.Y));
     }
     g.Dispose();
     picBoxMain.Invalidate();


 }
private void picBoxMain_MouseDown(object sender, MouseEventArgs e)
{
    
    shapestartP = e.Location;
}

This code is flawed as when u drag the cursor from bottom to up it stills draws the rectangle upwards. Any suggestions?
Was this page helpful?