Basically, you were mistaken in using the CreateGraphics method.
This is something you rarely, if ever, need to do. It is not as if the method was violated, of course. It does exactly what it says: it is documented as performing: it returns a Graphics object representing the surface of the drawing of your form.
The problem is that whenever your form is redrawn (which can happen for a variety of reasons), the Graphics object basically gets reset. As a result, everything that you painted in what you received is erased.
The form is always redrawn on first load, so using CreateGraphics never makes sense in the Load event handler method. It will also be redrawn at any time when it is minimized and restored, closed by another window or even resized (some of them depend on your operating system, graphics drivers, and the properties of your form, but outside the dot) sub>.
The only time you can use CreateGraphics is when you want to show immediate user feedback that should not be saved when redrawing. For example, in the MouseMove event handler when displaying feedback for drag and drop.
So what is the solution? Always execute the drawing inside the Paint event handler method. This way, it is saved during the redraw because the redraw basically involves creating a Paint event.
When the Paint event is raised, an instance of the PaintEventArgs class is PaintEventArgs , which contains a Graphics object that you can draw.
So what your code looks like:
Public Class Form1 Protected Overridable Sub OnPaint(e As PaintEventArgs) ' Call the base class MyBase.OnPaint(e) ' Do your painting e.Graphics.DrawLine(Pens.Azure, 10, 10, 20, 20) End Sub End Class
(Note also that in the above code, I override the OnPaint method rather than handling the corresponding Paint event. This is considered the best practice for handling events in a derived class. But it will work anyway.)