• Welcome to Valhalla Legends Archive.
 

[c#.net] working up the chain [solved]

Started by mentalCo., February 01, 2005, 05:52 PM

Previous topic - Next topic

mentalCo.

say i have a class named MyClass on my main form called Form1.  How do I call functions in Form1 from inside MyClass?

edit:

i solved it using events.

MyndFyre

Quote from: mentalCo. on February 01, 2005, 05:52 PM
say i have a class named MyClass on my main form called Form1.  How do I call functions in Form1 from inside MyClass?

edit:

i solved it using events.

Egad!  Why?  Why not just pass your Form instance to MyClass and then give your Form1 class some public instance-level functions?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

shout

A code example for MydnFyre's reply:

class MyClass
{
private Form1 whatnot;

public MyClass()
{
whatnot = new Form1();
}

private void blah()
{
whatnot.iamamethod();
}
}

MyndFyre

Quote from: shout on February 01, 2005, 08:15 PM
A code example for MydnFyre's reply:

class MyClass
{
private Form1 whatnot;

public MyClass()
{
whatnot = new Form1();
}

private void blah()
{
whatnot.iamamethod();
}
}


Yeah that's MyndFyre, thanks :P

Anyway, the reason this comes up is because VB6 people are used to just referencing their forms and crap via the name of the form rather than an instance variable.  If you make your MyClass object from within the Form, you can pass the instance of the Form as a parameter via "this".
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

mentalCo.

i dont know why i didnt think of that.  haha.  thanks.

shout

Sorry MyndFyre, but I am but a human who makes mistakes.