我以这种方式在c#中实现了一个向导:
private static void MyInitialization()
{
WizardData wData = new WizardData();
wData.FormToShow = WizardData.wizardForms.FirstStep;
Form step1 = new FirstStep(wData);
Form step2 = new SecondStep(wData);
Form step3 = new ThirdStep(wData);
while (wData.FormToShow != WizardData.wizardForms.Cancel)
{
switch (wData.FormToShow)
{
case WizardData.wizardForms.FirstStep:
{
step1.ShowDialog();
break;
}
case WizardData.wizardForms.SecondStep:
{
step2.ShowDialog();
break;
}
case WizardData.wizardForms.ThirdStep:
{
step3.ShowDialog();
break;
}
}
当我想要移动到另一种形式时,我需要关闭currnet(this.close),
,但我希望制作当前的visibility=false
并且当我转到其他形式时不会丢失当前表格中的数据?
private void btnNext_Click(object sender, EventArgs e)
{
// to show the SecondStep form
wData.FormToShow = WizardData.wizardForms.SecondStep;
this.Close();
}
任何想法?
答案 0 :(得分:2)
使用Hide()
方法
Form1.Hide();
这样,表单将不可见,并且数据将保存到表单的Dispose()
之前。