Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

"New Form" Instance problem

QariukiQariuki Member Posts: 8
Hi,
I have 3 forms, 1 MDI form and 2 other normal fomms.
I call my Form1 from the MDI Form and then Form1 calls Form2 (to do some search and return results to Form1). My only problem is that i don't know how to return to my Form1 since i have to create a new instance of Form1 whenever i want to show a it. This was very easy in VB6. Please HELP!!!
Qariuki.

Comments

  • paulmorrisonpaulmorrison Member Posts: 127
    : Hi,
    : I have 3 forms, 1 MDI form and 2 other normal fomms.
    : I call my Form1 from the MDI Form and then Form1 calls Form2 (to do some search and return results to Form1). My only problem is that i don't know how to return to my Form1 since i have to create a new instance of Form1 whenever i want to show a it. This was very easy in VB6. Please HELP!!!
    : Qariuki.
    :
    I think you will have to continue to create a new instance of the form. What I have done in similar situations is to use Public variables identified in every form. Then when the form is opened, it can use the data in these fields as appropriate.
  • raymcdraymcd Member Posts: 284
    : : Hi,
    : : I have 3 forms, 1 MDI form and 2 other normal fomms.
    : : I call my Form1 from the MDI Form and then Form1 calls Form2 (to do some search and return results to Form1). My only problem is that i don't know how to return to my Form1 since i have to create a new instance of Form1 whenever i want to show a it. This was very easy in VB6. Please HELP!!!
    : : Qariuki.
    : :
    : I think you will have to continue to create a new instance of the form. What I have done in similar situations is to use Public variables identified in every form. Then when the form is opened, it can use the data in these fields as appropriate.
    :

    Extend the mdiForm. Add a property that exposes a collection of child forms the same way the controls collection tracks controls. IMO that's the way to do it. Maybe create a custom pair of interfaces Like IMyMdiParent and IMyMdiChild. Use these to extend the form class so that children know how to add themselves to the parent. That's even better and it's the OOP way to do it. Anytime you need to communicate between two classes it's good to create one or more interfaces that define the communication. Well, maybe not "anytime" but its definitely clean.

    -ray
  • paulmorrisonpaulmorrison Member Posts: 127
    : : : Hi,
    : : : I have 3 forms, 1 MDI form and 2 other normal fomms.
    : : : I call my Form1 from the MDI Form and then Form1 calls Form2 (to do some search and return results to Form1). My only problem is that i don't know how to return to my Form1 since i have to create a new instance of Form1 whenever i want to show a it. This was very easy in VB6. Please HELP!!!
    : : : Qariuki.
    : : :
    : : I think you will have to continue to create a new instance of the form. What I have done in similar situations is to use Public variables identified in every form. Then when the form is opened, it can use the data in these fields as appropriate.
    : :
    : I found by removing some unneccessary code and reloading the Adapter for the dataset, I was able to do what I wanted to do. Thanks
    : Extend the mdiForm. Add a property that exposes a collection of child forms the same way the controls collection tracks controls. IMO that's the way to do it. Maybe create a custom pair of interfaces Like IMyMdiParent and IMyMdiChild. Use these to extend the form class so that children know how to add themselves to the parent. That's even better and it's the OOP way to do it. Anytime you need to communicate between two classes it's good to create one or more interfaces that define the communication. Well, maybe not "anytime" but its definitely clean.
    :
    : -ray
    :

Sign In or Register to comment.