Accessing base-form functions from other forms

X

Xarious

Hi all,
I need to bring up a form off of my base win form and then,
depending on which button the user clicks, perform a function that is
in my base form. I can create an instance and show the new form fine,
but I am unsure as how to perform function calls from the new form once
it has been shown.
If anyone could point me in the right direction that would be
grand. I have been googling around for about an hour now trying to
figure this out but I have been having a hard time describing my
problem in search terms. Thank you all in advance.
 
R

RobbGMelenyk

This may or may not help you. I've used it to access objects in my
main file (like an eventlog).

Instiate my class in main code section:
public class CSService : System.ServiceProcess.ServiceBase
{
public void Func()
{
Services services = new Services(this);
}
..
..
..
}

This is in another file:
public class Services
{
private CSService Parent;
public Services(CSService f)
{
//
// TODO: Add constructor logic here
//
Parent = f;
}
//So I now have access to my parent (calling) objects
Parent.eventLog1.WriteEntry("wahoooo");
}

Yes it's pretty rough and kind of a quick and dirty method but it does
work. My example was pulled from a service. I hope that helps a
little bit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top