title: Changing Form Label Text Outside of Form.h
body: <p>I am learning Visual C++ and have come across quite the stumbling block on Day 1. I am attempting to make a simple 'Hello World' application using the Form template in Visual C++ 2010.</p>
  
  <p>The solution created Form1.h, resource.h, stdafx.h, AssemblyInfo.cpp, helloworld.cpp, and stdafx.cpp. I added a button and a label to Form1 and was able to make it so that when the button is clicked the label changed text to "Hello World" from within Form1.h. I would like to do this from Form1.cpp though, so I stripped the code from the header. I currently have the following code:</p>
  
  <p>Form1.cpp</p>
  
  <pre><code>#include "stdafx.h"
  #include "stdio.h"
  #include "Form1.h"
  
  using namespace helloworld;
  
  
  helloworld::Void testButton_Click(System::Object^  sender, System::EventArgs^  e) {
      helloworld::Form1::label1-&gt;Text = "Test";
  }
  </code></pre>
  
  <p>Form1.h</p>
  
  <pre><code>#pragma once
  
  namespace helloworld {
  
      using namespace System;
      using namespace System::ComponentModel;
      using namespace System::Collections;
      using namespace System::Windows::Forms;
      using namespace System::Data;
      using namespace System::Drawing;
  
      /// &lt;summary&gt;
      /// Summary for Form1
      /// &lt;/summary&gt;
      public ref class Form1 : public System::Windows::Forms::Form
      {
      public:
          Form1(void)
          {
              InitializeComponent();
              //
              //TODO: Add the constructor code here
              //
          }
  
      protected:
          /// &lt;summary&gt;
          /// Clean up any resources being used.
          /// &lt;/summary&gt;
          ~Form1()
          {
              if (components)
              {
                  delete components;
              }
          }
      private: System::Windows::Forms::Button^  testButton;
      public: System::Windows::Forms::Label^  label1;
      protected: 
  
      private:
          /// &lt;summary&gt;
          /// Required designer variable.
          /// &lt;/summary&gt;testButton
          System::ComponentModel::Container ^components;
  
  #pragma region Windows Form Designer generated code
          /// &lt;summary&gt;
          /// Required method for Designer support - do not modify
          /// the contents of this method with the code editor.
          /// &lt;/summary&gt;
          void InitializeComponent(void)
          {
              this-&gt;testButton = (gcnew System::Windows::Forms::Button());
              this-&gt;label1 = (gcnew System::Windows::Forms::Label());
              this-&gt;SuspendLayout();
              // 
              // testButton
              // 
              this-&gt;testButton-&gt;Location = System::Drawing::Point(136, 159);
              this-&gt;testButton-&gt;Name = L"testButton";
              this-&gt;testButton-&gt;Size = System::Drawing::Size(75, 23);
              this-&gt;testButton-&gt;TabIndex = 0;
              this-&gt;testButton-&gt;Text = L"Test Button";
              this-&gt;testButton-&gt;UseVisualStyleBackColor = true;
              this-&gt;testButton-&gt;Click += gcnew System::EventHandler(this, &amp;Form1::testButton_Click);
              // 
              // label1
              // 
              this-&gt;label1-&gt;AutoSize = true;
              this-&gt;label1-&gt;Location = System::Drawing::Point(125, 100);
              this-&gt;label1-&gt;Name = L"label1";
              this-&gt;label1-&gt;Size = System::Drawing::Size(35, 13);
              this-&gt;label1-&gt;TabIndex = 1;
              this-&gt;label1-&gt;Text = L"label1";
              // 
              // Form1
              // 
              this-&gt;AutoScaleDimensions = System::Drawing::SizeF(6, 13);
              this-&gt;AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
              this-&gt;ClientSize = System::Drawing::Size(284, 262);
              this-&gt;Controls-&gt;Add(this-&gt;label1);
              this-&gt;Controls-&gt;Add(this-&gt;testButton);
              this-&gt;Name = L"Form1";
              this-&gt;Text = L"Form1";
              this-&gt;Load += gcnew System::EventHandler(this, &amp;Form1::Form1_Load);
              this-&gt;ResumeLayout(false);
              this-&gt;PerformLayout();
  
          }
  #pragma endregion
      private: System::Void testButton_Click(System::Object^  sender, System::EventArgs^  e) ;
  private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
           }
      };
  }
  </code></pre>
  
  <p>With this code I receive the following error:</p>
  
  <pre><code>error C2227: left of '-&gt;Text' must point to class/struct/union/generic type
  </code></pre>
  
  <p>From what I have found, that error means that the program doesn't know what I am talking about with <code>label1-&gt;Text</code>. I would greatly appreciate any help that could be given to a Visual C++ newbie.</p>