Welcome to Dream.In.Code
Become a C++ Expert!

Join 150,243 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,345 people online right now. Registration is fast and FREE... Join Now!




Accessing components on other form

 
Reply to this topicStart new topic

Accessing components on other form

chrisliando
5 Nov, 2007 - 07:21 PM
Post #1

New D.I.C Head
*

Joined: 5 Nov, 2007
Posts: 3

Hi everyone, I am working on application with more than 1 form but I don't use MDI. In form1 I have a treeView and a ListView. On form2, I have a textBox and a button. The flow is when I click the button on form2, the treeView on form1 will add new node.

I've tried this one but it is error and I don' understand the error:

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Form1->treeView1->Nodes->Add(textBox1->Text);
}

Thank you very much.
User is offlineProfile CardPM
+Quote Post

baavgai
RE: Accessing Components On Other Form
5 Nov, 2007 - 08:31 PM
Post #2

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,285



Thanked: 136 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua, Cheese

My Contributions
Regardless of how you go, you'll want to put some kind of event on form2 that's public. You can make the button click event public, if you like. The it's usually cleaner to write a specific event for sharing outside a parent form.

If Form1 instantiates Form2, have it listen to the event of the instance it created and react accordingly. If Form1 and Form2 share a parent, have the parent listen to the form2 event and tell form1 what happened.

Some kind of event pattern is pretty much the only solution is you want to react to a button press.

User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/9/09 06:37AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month