title: Graphics not showing up on UserControl in C#
body: <p>Calling a RedrawLines() method in the Paint Event that was effective but I made some minor changes that should have had no effect and now I'm having issues. First of all, when I switch tabs, each of which contain my UserControl, the lines are not redrawing as they did before. Furthermore, when I use the MouseWheel, the lines are not drawn entirely, as in they are cut off at the top and bottom of the UserControl. Yet, when I use the ScrollBar, they are drawn in their entirety. Any idea?</p>
  
  <p>Here is part of my DrawLine() method after getting the points necessary:</p>
  
  <pre><code>System.Drawing.Pen myPen;
  myPen = new System.Drawing.Pen(Color.Black);
  myPen.Width = 3;
  System.Drawing.Graphics formGraphics = this.CreateGraphics();
  
  formGraphics.DrawLine(myPen, p1.X, p1.Y, p2.X, p2.Y);
  myPen.Dispose();
  formGraphics.Dispose();
  </code></pre>
  
  <p>so then I have a RedrawLines method that calls this accurately</p>
  
  <pre><code>private void RedrawLines(){
      Graphics g = Graphics.FromHwnd(this.Handle);
      g.Clear(Color.White);
      g.Dispose();
      for (int i =0; i &lt; Set_Of_Connections.Count; i++)
      {
           DrawLine(Set_Of_Connections[i].ins.cb, Set_Of_Connections[i].outs.cb, Color.Green);
      }
  }
  </code></pre>
  
  <p>call this in the Paint Event:</p>
  
  <pre><code>private void Switch_Paint(object sender, PaintEventArgs e)
  {
      RedrawLines();
  }
  </code></pre>
  
  <p>But like I said this probably isn't going to help you at all.</p>