Hi!
I use this code to draw rectangles while mouse is clicked in Panel.
The rectangle is drawn in the position of the click.
For now it works good but each time i click in new location in the Panel, the previous rectangle is deleted.
This is my code to draw:
Thanks in advance!
I use this code to draw rectangles while mouse is clicked in Panel.
The rectangle is drawn in the position of the click.
For now it works good but each time i click in new location in the Panel, the previous rectangle is deleted.
This is my code to draw:
Code:
private void click_AddLocation(object sender, EventArgs e)
{
.
.
.
.
this.Panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.PaintOnMap);
Panel1.Refresh();
}
private void PaintOnMap(object sender, PaintEventArgs e)
{
RedPen = new Pen(Color.Red, 7);
Graphics g = e.Graphics;
PosXDraw = PosX;
PosYDraw = PosY;
Rect = new Rectangle(PosXDraw * 3, PosYDraw * 3, 1, 1);
g.DrawRectangle(RedPen,Rect);
}
Comment