title: Can't view designer when coding a form in C#
body: <p>I'm following <a href="http://www.yevol.com/en/vcsharp/applicationdesign/Lesson03.htm" rel="nofollow">this</a> tutorial on winforms, and so far the tutorial is coding the form without using the toolbox. I believe it'll introduce the toolbox in more depth shortly.</p>
  
  <p>Following the tutorial, I've made a partial class in the following two pieces of code:</p>
  
  <p><em>First file</em>:</p>
  
  <pre><code>using System;
  using System.Windows.Forms;
  
  public class Numeric : System.Windows.Forms.TextBox
  {
      public Numeric()
      {
      }
  }
  
  public partial class Exercise
  {
      private Numeric txtbox;
      System.ComponentModel.Container components;
  }
  </code></pre>
  
  <p><em>Second file</em>:</p>
  
  <pre><code>using System;
  using System.Windows.Forms;
  
  public partial class Exercise : Form
  {
      private void InitializeComponent()
      {
          txtbox = new Numeric();
          Controls.Add(txtbox);
      }
  
      public Exercise()
      {
          InitializeComponent();
      }
  }
  
  public class program
  {
      public static int Main()
      {
          Application.Run(new Exercise());
          return 0;
      }
  }
  </code></pre>
  
  <p>When I run the code with F5, everything looks fine: The form pops up with the textbox.</p>
  
  <p>But for some reason, when I right-click on the second file and choose "View Designer", I get an error which says "The variable 'txtbox' is either undeclared or was never assigned". I can choose to "Ignore and Continue", which leads me to a form with no textbox on it.</p>
  
  <p>Why does this occur? I know some of you think I should just use the toolbox, and it's probably the most sensible thing to do, but I would still like to understand why this happens.</p>