简体   繁体   中英

parameter passing issue

I have a parameter passing problem.

I have 2 forms. Form A which is the main form and Form B which is opened from Form A.

In Form AI have a List of objects of a certain type. Form B's job is to create a new object for Form A to add to the said List. So when Form B creates an object from user inputed data, I need it to pass the object to Form A and then it closes. This is where my question is, what logic do I use to pass the created object to the parent Form?

Pseudocode example:

Class Form A: { Variable declaration List a; Form B;

Action: Button pressed; Show Form B

}

Class Form B:

{ Variables: textField 1, textField 2;

Action: Submit button pressed; Create new Obj with values entered in textFields }

When the new object is created in Form B, Form B will close, and I want the object to be added to the list in Form A.

Thanks in advance

It depends on how complex your application is. In an simply application I would pass a reference of Form A to Form B. When Form B closes it can call a method of Form A to pass the created object and refresh itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM