How to call the owner's method in a windows form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

FormA is the owner of FormB, and when the FormB is closed, I want to call a method in FormA
I've tried in this way
FormA frm=(FormA)FormB.Owner
But I cannot find the method I need in the variable "frm"
Please help. Thanks a lot!
 
Hi Toto,

The reason could be that the FormA's method in question doesn't have proper
visiblity set.
The other reason might be that the actual type of the FormA is not FormA,
but some of its descendants and this method is defined not in FormA class,
but in some other class that inherits from class FormA.

I believe we could help you better if you post some code that demonstrates
the problem. Otherwise we could only guess.
 
Toto said:
FormA is the owner of FormB, and when the FormB is closed, I want to call a method in FormA.
I've tried in this way:
FormA frm=(FormA)FormB.Owner;
But I cannot find the method I need in the variable "frm".
Please help. Thanks a lot!

Perhaps you should raise an event in FormB? FormA could listen for that
event. So could any other form which might be interested later in your
development.
 
Back
Top