Function calls across forms

  • Thread starter Thread starter Shaun Pudwell
  • Start date Start date
S

Shaun Pudwell

Hi, I am very new to C#, so this may seem to simple to be
true. Anyway, the problem is this: I have my MainWindow
class and an MDI child window and its associated class.
The class MainWindow class has a function called
DrawChart. My MDI child needs to make a call to DrawChart.

Now I know I can say something along the lines of...

MainWindow xxx = new MainWindow ();
xxx.DrawChart ();

The problem here is I have a counter in the MainWindow
class, which gets reset every time a call to new
MainWindow (); is made. How do I call this function from
my MDI child window and keep the existing values inside
the MainWindow class?

Thanks in advance,
Shaun Pudwell.
 
Shaun, you need to keep a reference to your original MainWindow object. You
could do this by passing the object around or by creating a class level
variable and storing the reference there. If you want to call MainWindow
from your other form make sure to pass a reference to the other form
pointing to your original MainWindow object.
 
Back
Top