multiple forms

  • Thread starter Thread starter ulazar
  • Start date Start date
U

ulazar

I would like to open a form from a button in the principal form. Ok
that's easy...the problem is that I want to use methods, variables of
principal application and access to data source from the second form.
 
I would like to open a form from a button in the principal form. Ok
that's easy...the problem is that I want to use methods, variables of
principal application and access to data source from the second form.

As long as your methods, variables (make that properties) and data
source are public, you can access them from the main form..

mySecondForm.DoSomething();
int x = mySecondForm.AProperty;

Remember that the object you define in the main form

myForm mySecondForm = new MyForm();

will need to be given sufficient scope so that you have access to
it... e.g. don't make it local ot the button click event unless that's
where you want all the processing to be.

Cheers
 

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

Back
Top