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 :-)

Recommended Answers

All 3 Replies

The easiest way is to send the value from one dialog to another is to use PostMessage().

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.