How to make a label in form2 equal a textbox in form 1?

Hi

I need help making a label in Form2 = a textbox in Form1.

I keep getting the following errors.
c:\users\hamish\documents\visual studio 2010\projects\7hund3r570rm\7hund3r570rm\7hund3r570rmTextTest.h(29): error C2275: 'My7hund3r570rm::Form1' : illegal use of this type as an expression
1> c:\users\hamish\documents\visual studio 2010\projects\7hund3r570rm\7hund3r570rm\Form1.h(18) : see declaration of 'My7hund3r570rm::Form1'
1>c:\users\hamish\documents\visual studio 2010\projects\7hund3r570rm\7hund3r570rm\7hund3r570rmTextTest.h(29): error C2227: left of '->textBox3' must point to class/struct/union/generic type
1>c:\users\hamish\documents\visual studio 2010\projects\7hund3r570rm\7hund3r570rm\7hund3r570rmTextTest.h(29): error C2227: left of '->Text' must point to class/struct/union/generic type
1> 7hund3r570rm.cpp
1>c:\users\hamish\documents\visual studio 2010\projects\7hund3r570rm\7hund3r570rm\7hund3r570rmTextTest.h(29): error C2065: 'Form1' : undeclared identifier
1>c:\users\hamish\documents\visual studio 2010\projects\7hund3r570rm\7hund3r570rm\7hund3r570rmTextTest.h(29): error C2227: left of '->textBox3' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\hamish\documents\visual studio 2010\projects\7hund3r570rm\7hund3r570rm\7hund3r570rmTextTest.h(29): error C2227: left of '->Text' must point to class/struct/union/generic type


My code:
#pragma once

#include "Form1.h"


namespace My7hund3r570rm {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


/// <summary>
/// Summary for My7hund3r570rmTextTest
/// </summary>
public ref class My7hund3r570rmTextTest : public System::Windows::Forms::Form
{
public:
My7hund3r570rmTextTest(void)
{
InitializeComponent();

//
//TODO: Add the constructor code here
//
this->label1->Text = Form1->textBox3->Text;
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~My7hund3r570rmTextTest()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
protected:
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(My7hund3r570rmTextTest::typeid));
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(53, 9);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(35, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"label1";
this->label1->Click += gcnew System::EventHandler(this, &My7hund3r570rmTextTest::label1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(53, 22);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(35, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"label2";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(53, 35);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(35, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"label3";
//
// My7hund3r570rmTextTest
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(141, 57);
this->ControlBox = false;
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"My7hund3r570rmTextTest";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"7hund3r570rm Text Test";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {

}
};
}

Thanks
Hamish
Topic archived. No new replies allowed.