communication between two forms

  • Thread starter Thread starter rammohan
  • Start date Start date
R

rammohan

hello
my task is to show only one form at a time.if click
some button in one form the other must be displayed and
viceversa. i try it but i got debugger exception. can u
give me the reason why so.

regards
--rammohan
 
Why not have a controller class that holds references to both forms?
This should work easily and keeps you forms clean:

class SingletonFormController
{
private Form FormA;
private Form FormB;

public void ShowFormA()
{
FormB.Visible = false;
FormA.Visible = true;
}
}

Cheers, Philipp
 
He was asking what to do when pressing buttons
and wanting to activate different forms consecutively.

How does your advice answer his query?
Perhaps you might add some more code lines
to show the solution to his problem more clearly ?
 
Vanessa said:
He was asking what to do when pressing buttons
and wanting to activate different forms consecutively.
How does your advice answer his query?


private void MyButton_Click(object sender, EventArgs e)
{
SingletonFormController.Instance.ShowFormA();
}

I hope you don't mind that I skipped the class declaration ;-)

Philipp
 
Back
Top