Using C++/CLI--
Is there a good way to return a value (not a DialogResult) from a form shown as a dialog?

I plan to use Invoke on a method to update the previous form from within the dialog, if not.

I also would like to thank the fine members of Daniweb for being so helpful, as always.

Not sure what your asking. You have Form1 that invokes Form2 and you want Form2 to return something to Form1?

Yes that is correct, ancient dragon.

Here is an example where Form1 copies the text from Form2 after Form2 closes. In Form2.h I added a public method that return the String from its textBox1 text control. Similar technique can be used for all of the controls on Form2.

Form2.h

public:
        String^ GetTextBoxString() { return textBox1->Text; }

Form1.h This method is envoked when a button control is clicked.

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 Form2^ f2 = gcnew Form2;
                 this->Hide();
                 f2->ShowDialog();
                 this->textBox1->Text = f2->GetTextBoxString();
                 this->Show();
             }
    };
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.