Hi, I have 7 forms in my project. Form 6 has a text box, I wish for the text entered in Form 6 to be passed to a label in Form 7. I am new to C++ and would really appreciate any advice. I have posted the code I am trying to work with but i keep getting error C2248. Please Help!! Thanks. Code: public ref class Form6 : public System::Windows::Forms::Form { public:String^str1; public: Form6(void) { InitializeComponent(); // //TODO: Add the constructor code here // } #pragma endregion private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Application::Exit(); } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { Application::Exit(); } private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) { this->textBox2->Text = this->textBox1->Text; this->textBox1->Text = ""; this->textBox1->Text = "Saved"; } private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) { } public: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { str1 = this->textBox2->text; Form6::Hide(); Form7 myForm; if(myForm.ShowDialog() == System::Windows::Forms::DialogResult::OK) { //Do stuff } } private: System::Void Form6_Load(System::Object^ sender, System::EventArgs^ e) { str1 = "str1default"; } private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) { str1=textBox2->Text; } }; }
Compiler Error C2248 Error Message 'member' : cannot access 'access' member declared in class 'class' Which line throws the error?
Hi, Thanks very much for replying. As you can see I am new to this!! I really appreciate your feedback. I have copied the line (Line 281) which throws the error below: public: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { this->textBox2->text=str1;//this line throws the C2248 error Form6::Hide(); Form7 myForm; if(myForm.ShowDialog() == System::Windows::Forms:ialogResult::OK) { //Do stuff }
Hi, I have changed "public" to "private" which has solved the C2248 error Thanks. My problem now is when debugging I click to load Form7 which should have the text from Form6 but there is nothing there not even the textbox?? If you can offer me any advice that would be great. Thanks