My problem is about drawing line. In my form, I have a button and if I click the button some data is taken from a database (coordinates). Based on this coordinates, I want to draw lines on a panel. Under button_click event I wrote this code:
Pen myPen = new System.Drawing.Pen(Color.Black, 1); Graphics formGraphics; formGraphics = panel1.CreateGraphics(); formGraphics.DrawLine(myPen, x1, y1, x2, y2); myPen.Dispose(); formGraphics.Dispose();
I can draw the lines with this code, but if I minimize the form and open again, all lines disappear. The form is redraw again. I put some pictures also on panel. Pictures doesn't disappear.
I know I have to use panel_paint event but I have no idea how I can use panel_paint event and button_click event.
Can you give a small example about it.