I created 2 window form using visual C++, I am trying to display the string typed by user in second window form's textbox.

Here is what i wrote, but the code is not working:


private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

Any help or advice is welcome.....I need this urgently...thanks...

System::Windows::Forms:: DialogResult dr;
dr = form2().ShowDialog();
if(dr==System::Windows::Forms:: DialogResult::OK )
String^ strmsg=form2().textBox1->Text;
MessageBox:: Show(strmsg);

I also tried this method but message box show nothing...why?

Any help??? Any advice or idea are welcome....

How come nobody have comment on this? I need this urgently..Pls help me....

Million thanks in advance.

The code looks strange (I'm in a hurry now and can't explain in details),
anyway try something like;

form2 frm;
MessageBox:: Show(frm.textBox1->Text);