We help IT Professionals succeed at work.

C++ Windows Form - Passing values between Forms

banana_split
banana_split asked
on
3,182 Views
Last Modified: 2008-01-09
Hi i would like to ask, for example if i have 2 Forms. Form1 and Form2 and i want to pass for example a value (example 0) to Form B, what function in c++ should i use?


Thanks.
Comment
Watch Question

Commented:
It depends what is relation between two forms. If FormB is opened from FormA as modal dialog, you can set FormB member directly:

FormB^ b = gcnew FormB();
b->data = ...;   // set some value
d->ShowDialog(this);

Author

Commented:
if i am now at Form1 and my application starts from Form1 and i want to pass some values to Form2?


And this is where is start form2

private: System::Void pictureBoxGo_Click(System::Object^  sender, System::EventArgs^  e) {
                        Form2^ f = gcnew Form2();
                        this->Hide();
                        f->ShowDialog(this);
                        this->Show();
                   }

how should i go about passing the data over to form2?
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.