tags:

views:

119

answers:

1

I have a main form, and some sub forms, and each sub form can have some sub forms. When I have multiple sub forms open, and I try to get data from the parent form, it returns the data from the wrong parent form.

For example I have two instances of Mainform.subform running. If I do something like this in a child form of one instance of the subform. It returns data from the other subform.

 dim l = Mainform.subform.listofdata

Edit I am using visual Studio 2008. Winforms, form designed using designer.

In my mainform I am doing this

 Protected Friend frmMain as Mainform
 frmmain = new mainform

In frmMain I am doing this

Protected Friend  frmsub as new Subform'
frmsub = new subform

In the SubSubForm I am doing this

 For each item in frmmain.frmsub.listofdata
 \\Do Something
next
A: 

You may want to consider setting the Parent property of the child forms, and then use the parent/child relationship to find the correct listofdata that you're looking for. Something like Me.Parent.listofdata. Hopefully this is an option in your particular case - good luck!

Mike