问题描述:

I have multiple forms and i can make them all go to a certain form through the click of one button, but how do I give one button the ability to go back to the last page the user was on, and not just the form before the current one? This is for my 'help' form, as users can visit the form through many other forms. My coding was as follows. I am using Winforms

namespace Spanish_Quiz

{

public partial class Help : Form

{

public Help()

{

InitializeComponent();

CenterToScreen();

}

private void btnBackToStart_Click(object sender, EventArgs e)

{

Homescreen Homescreen = new Homescreen();

Homescreen.Show();

Homescreen.Activate();

this.Hide();

}

private void btnBack_Click(object sender, EventArgs e)

{

/*This is where my problem is,

what code do I write here that could be similar to

my 'back to start' button's code?*/

}

}

}

网友答案:

There are several options, i would do it with ShowDialog, before showing the help form, hide the current form, and after closing help form, show the current form again. like this:

Form SomeForm {

    private void OpenHelpForm(object sender, EventArgs e){
        this.Hide();
        new Help().ShowDialog(); //this opens the form and pauses the current form. 

        //when Help form closes, this method continues
        this.Show();
    }
}
相关阅读:
Top