如何隐藏WinForms表单而不丢失它的数据
本文关键字:数据 表单 何隐藏 隐藏 WinForms | 更新日期: 2023-09-27 18:18:42
我用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();
}
任何想法?
使用Hide()
方法
Form1.Hide();
这样,表单将不可见,数据将被保存,直到您Dispose()
的表单。