title: C# Checkbox: The name ... does not exist in the current context
body: <p>I'm having an issue with VS2010 C#:</p>
  
  <p>I have created a Checkbox on my form named 'chkVehicles', in my Form1.cs I am trying to determine if the checkbox is checked, but I receive the error message:
  "The name 'xVehicles' does not exist in the current context"</p>
  
  <p>(My code works fine apart from the Checkbox...)</p>
  
  <p>Form1.cs:</p>
  
  <pre><code>namespace plottingMap
  {
      public partial class MapForm : Form
      {
          Map mapData = new Map();
  
          public MapForm()
          {
              InitializeComponent();
              &lt;..snip...&gt;
          }
  
          &lt;...snip...&gt;
  
          private void chkVehicles_CheckedChanged(object sender, EventArgs e)
          {
              CheckBox xVehicles = (CheckBox)sender;
          }
  }
  
  class Map
  {
      &lt;...snip...&gt;
  
      if (carpool.Contains(name) &amp;&amp; xVehicles.Checked)
      {
          &lt;...snip...&gt;
      }
      &lt;...snip...&gt;
  }
  </code></pre>
  
  <p>Thanks</p>