Good day/night to all;

As the title says, its really troublesome.
Lets say i have form1 and form2
i want form1 to hide while form2 shows, what i do is get a button and use this code:

Form2 trials = new Form2();
            trials.Show();
            this.Hide();

this will hide form1 and show form2

now my question is how can i close form2 and show the hiding form1 again.
I dont want to make a new form1 but show the hiding form1 herself.(yes, form1 is a girl xD)

thank you in advance.

Recommended Answers

All 4 Replies

Does Form1.Show() cannot do the trick?

@ddanbe
form1.show();
generates me a new form1 and let my hidden form1 just there, hidden

Then have a read here

that didnt help but thank you,,, I have already solved my problem in other forum. it told me to use constructors. anyway i will paste it here for reference

private System.Windows.Forms.Form fCaller;

public Form2(Form f)
{
this.fCaller = f;
this.InitializeComponent();
}

private void Form2_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
this.fCaller.Show();
}

Here is the code on Form1.

private void button1_Click(object sender, System.EventArgs e)
{
Form2 myForm2 = new Form2(this);
myForm2.Show();
this.Hide();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.