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;}