title: How to declare a button event in a class?
body: <p>i'm new here and hope you can help me...
  i've got a header "Messagebox.h" for my window layout (i'm using visual studio 2013) and i want to declare the click-event in a class "Class.cpp" instead of the header.</p>
  
  <p>this is my Messagebox.h</p>
  
  <pre><code>#pragma once
  
  class Banana;
  class Apple;
  
  namespace Fruitsalat {
  
  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;
  /// Zusammenfassung für Messagebox
  /// &lt;/summary&gt;
  public ref class Messagebox : public System::Windows::Forms::Form
  {
  public:
      Messagebox(void)
      {
          InitializeComponent();
          //
          //TODO: Konstruktorcode hier hinzufügen.
          //
      }
  
  protected:
      /// &lt;summary&gt;
      /// Verwendete Ressourcen bereinigen.
      /// &lt;/summary&gt;
      ~Messagebox()
      {
          if (components)
          {
              delete components;
          }
      }
  private: System::Windows::Forms::Button^  button1;
  private: System::Windows::Forms::Button^  button2;
  private: System::Windows::Forms::TextBox^  textBox1;
  protected:
  
  private:
      /// &lt;summary&gt;
      /// Erforderliche Designervariable.
      /// &lt;/summary&gt;
      System::ComponentModel::Container ^components;
  
  #pragma region Windows Form Designer generated code
      /// &lt;summary&gt;
      /// Erforderliche Methode für die Designerunterstützung.
      /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
      /// &lt;/summary&gt;
      void InitializeComponent(void)
      {
          this-&gt;button1 = (gcnew System::Windows::Forms::Button());
          this-&gt;button2 = (gcnew System::Windows::Forms::Button());
          this-&gt;textBox1 = (gcnew System::Windows::Forms::TextBox());
          this-&gt;SuspendLayout();
          // 
          // button1
          // 
          this-&gt;button1-&gt;Location = System::Drawing::Point(197, 226);
          this-&gt;button1-&gt;Name = L"button1";
          this-&gt;button1-&gt;Size = System::Drawing::Size(75, 23);
          this-&gt;button1-&gt;TabIndex = 0;
          this-&gt;button1-&gt;Text = L"quit";
          this-&gt;button1-&gt;UseVisualStyleBackColor = true;
          this-&gt;button1-&gt;Click += gcnew System::EventHandler(this, &amp;Messagebox::button1_Click);
          // 
          // button2
          // 
          this-&gt;button2-&gt;Location = System::Drawing::Point(102, 226);
          this-&gt;button2-&gt;Name = L"button2";
          this-&gt;button2-&gt;Size = System::Drawing::Size(75, 23);
          this-&gt;button2-&gt;TabIndex = 1;
          this-&gt;button2-&gt;Text = L"send";
          this-&gt;button2-&gt;UseVisualStyleBackColor = true;
          this-&gt;button2-&gt;Click += gcnew System::EventHandler(this, &amp;Messagebox::button2_Click);
          // 
          // textBox1
          // 
          this-&gt;textBox1-&gt;Location = System::Drawing::Point(12, 12);
          this-&gt;textBox1-&gt;Multiline = true;
          this-&gt;textBox1-&gt;ReadOnly = true;
          this-&gt;textBox1-&gt;Name = L"textBox1";
          this-&gt;textBox1-&gt;BackColor = Color::White;
          this-&gt;textBox1-&gt;Size = System::Drawing::Size(260, 195);
          this-&gt;textBox1-&gt;TabIndex = 2;
          // 
          // Messagebox
          // 
          this-&gt;AutoScaleDimensions = System::Drawing::SizeF(6, 13);
          this-&gt;AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
          this-&gt;ClientSize = System::Drawing::Size(284, 261);
          this-&gt;Controls-&gt;Add(this-&gt;textBox1);
          this-&gt;Controls-&gt;Add(this-&gt;button2);
          this-&gt;Controls-&gt;Add(this-&gt;button1);
          this-&gt;Name = L"Messagebox";
          this-&gt;Text = L"Messagebox";
          this-&gt;ResumeLayout(false);
          this-&gt;PerformLayout();
  
      }
  #pragma endregion
  
  private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
      this-&gt;Close();
  }
  private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e){
      //declare this in Apple.cpp or Banana.cpp
  }
  };
  }
  </code></pre>
  
  <p>can i do that and how?</p>