Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a method on another form/class....

Status
Not open for further replies.

MattWoberts

Programmer
Oct 12, 2001
156
GB
Hi,

I have a form, "X", that creates an instance of form "Y", and shows it via y.Show()..what I need to do is have Y call a method from the form X. Its probably really easy but I dont know how to do it...can anyone help?

 
Create a public method on Y that accepts a reference to X as a parameter and have X call it before calling Y.show().

For instance:

On Y
Code:
 public void setParent(X parentForm)
 {
   m_parentForm = parentForm;
 }

Then you would have X call
Code:
 Y.setParent(self);
 Y.show();

Now Y will have a reference to X and can call any public methods on it.



“I have always found that plans are useless, but planning is indispensable.” --Dwight Eisenhower
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top