|
なんとなく書いてみた。
Form currentForm; // 開いているフォーム
Form nextForm; // 次に開くフォーム
private void mainloop()
{
while (nextForm != null)
{
currentForm = nextForm;
nextForm = null;
currentForm.ShowDialog();
}
}
private void button1_Click(object sender, EventArgs e)
{
nextForm = new Form2();
nextForm.FormClosing += new FormClosingEventHandler(Form2_FormClosing);
mainloop();
}
void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
nextForm = new Form3();
nextForm.FormClosing += new FormClosingEventHandler(Form3_FormClosing);
}
void Form3_FormClosing(object sender, FormClosingEventArgs e)
{
nextForm = new Form2();
nextForm.FormClosing += new FormClosingEventHandler(Form2_FormClosing);
}
|