I m having problem with accessing one form (project1) value in another form(project2).

I m using VC++ 2008 express edition and i m doing my project pure vc++.

I have to store the the project1's textBox value in project2's textBox..

Please help me to resolve this problem.

Thanks in Advance :-)

8 Years
Discussion Span
Last Post by jonsca

Ho Ok..
But how to use postmessage()..
i google for that . but i didnt get proper answer..
i m using clr windows forms...


One way to do it is to have your project2 constructor take a variable of type TextBox. When you instantiate project2 from project1, pass in the textbox from project1. If you're launching them the other way around change the constructor in project1 to receive the TextBox.


#include "Form2.h"
private: Form2 ^ form2;
private: System::Windows::Forms::TextBox^ tbForm1;

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
      form2 = gcnew Form2(tbForm1);

This assumes you'll show form2 when form1 loads, but this is just an example.

The other alternative is to make the TextBox a public member and accessing it in the other class by using project1.membervariable . If that's the route you go make sure your headers are all included in the proper place.

Edited by jonsca: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.