Passing Data Between Currently Opened Forms

adshocker

Well-known member
Joined
Jun 30, 2007
Messages
180
Programming Experience
Beginner
hi all,

i've searched the forums and found topics regarding passing data from parent to child. most cases, i see parent to child but i haven't seen anything yet about child to parent or child to another child. also, my main concern which is basically passing data between forms (child to child or child to parent) that have been already loaded... called by a main MDIForm... which is the situation that i'm currently in.

can anyone show a sample on how to do this?

thanks.
 
You could create a property in the child form and you can read and write it from the parent form.

Another option is to create a delegate and pass it to the child form and have the child form call it.

I think any way you slice it, you'll have to go through the parent to get to another child form from a child form.

Rob
 
The mdi child form have a MdiParent property, there's your reference to the parent form. From there communication is the same as between any class instance, a form is just a class.

If the child created another child (of the parent) then that child already have the reference to the other child, if not you could go up through MdiParent and down through MdiChildren. Or have methods in parent that child can call to have the parent manage the whole thing from top down.
 
not sure if its the same situation but my MDI calls a ChildForm then this ChildForm calls another form (not an MDIChild, just a regular form) and this form will be the one to send a data to the ChildForm.

can i use the property method here?
 
There's Owner property, you can also write your own property if the implied behavior of owned forms doesn't suit you.
 
Back
Top