title: How to remove a line which is drawn on a form
body: <p>I'm trying to draw a triangle like this:</p>
  
  <pre><code>Dim triangle As Graphics
      Dim pen1 As New Pen(Color.LimeGreen, 2)
      Dim lside As Integer
      Dim wside As Integer
      Dim dside As Integer
  
  triangle = Me.CreateGraphics()
  triangle.DrawLine(pen1, wside, 420, 640, 420)
  triangle.DrawLine(pen1, 640, lside, 640, 420)
  triangle.DrawLine(pen1, dside, 420, 640, lside)
  </code></pre>
  
  <p><code>lside</code>, <code>wside</code> and <code>dside</code> stand for length side, width side and diagonal side.</p>
  
  <p>I've got 4 textboxes, for the length, width, diagonal side and one for the angle.
  The purpose is to fill in 2 of the values, and then a rectangular triangle gets drawn following Pythagoras' theorem. I want to draw a line for Angle as well later on. But I first want to get this to work.</p>
  
  <p>But every time I click the button to draw a new triangle, the previous one should get deleted. And that's the problem.</p>
  
  <p>I've tried multiple methods, like triangle.Dispose triangle.Restore triangle.Clear and more. None of them work. </p>
  
  <p>Why am I not drawing them in a picturebox you might ask. Well, when I drew a line in a picturebox, the picturebox sort of went in front of the line, making the line invisible. And I didn't know how to fix that.</p>