Christiawan

Hi everyone,

I am developing an application which I plan to use more than 1 form. I don't use MDI so how can I get access to components on the other form In my application, I have to access treeView components on the Form1 from the Form2. So when I click the button on Form2, the treeView on the Form1 automatically add new nodes.

I've tried to add codes like this:

private: System::Void button1_Click(System:Surprisebject^ sender, System::EventArgs^ e) {
WindowsForm::NewForm ^Form1 = gcnew WindowsForm::NewForm();
WindowsForm::NewForm::Form1->treeView1->Nodes->Add(textBox1->Text);
}

I look forward to hear from you soon.

Thank you very much for your kind help and support.

Christiawan.



Re: Visual C++ Express Edition Accessing Components on Another Form

Sheng Jiang (?κΙ)

You create a new Form1 everytime you click the button I think you need to reconsider your design. The Passing Data Between Objects in an Application article may help you.






Re: Visual C++ Express Edition Accessing Components on Another Form

Christiawan

No, I just want to SHOW another form but I don't understand that's why I create the form everytime I click the button. I still don't understand by reading the article you gave me. Do you have any code example to make it more clearly

Thank you very much.





Re: Visual C++ Express Edition Accessing Components on Another Form

Sheng Jiang (?κΙ)

If you want to show another form, fire an event and handle the event in the owner of the form to show the other form.






Re: Visual C++ Express Edition Accessing Components on Another Form

Christiawan

Thanks for the information you gave.

I still don't understand how to control the component on the other form I've tried the way you just told me but it still error.

Do you have a few lines of code so that I have idea

Thanks very much for your help.