Hi BillWoodruff! Thanks for your answer.
Line is drawn from the following functions, this function is called in the keydown event of the form.
public void DrawLine(PictureBox pb, Point p, Color color)
{
try
{
Point p1 = new Point();
Point p2 = new Point();
Point p3 = new Point();
Point p4 = new Point();
p1.X = p.X;
p1.Y = p.Y - 10;
p2.X = p.X;
p2.Y = p.Y + 10;
p3.X = p.X - 10;
p3.Y = p.Y;
p4.X = p.X + 10;
p4.Y = p.Y;
pb.Refresh();
Bitmap bmp = (Bitmap)pb.Image;
Graphics g = Graphics.FromImage(bmp);
Pen pe = new Pen(color, 3);
g.DrawLine(pe, p1, p2);
g.DrawLine(pe, p3, p4);
pb.Image = bmp;
pe.Dispose();
g.Dispose();
}
catch
{
MessageBox.Show("Please select image let draw!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
And when the user draw a new line, the line has been drawn previously been removed.