我創建了一個加載表單,但我想訪問加載表單並加載其他表單。我知道有一種方法可以實現這一點,但我認爲的方式是創建另一個加載表單並訪問另一個加載表單來加載不同的表單,即使加載表單內容相同。創建一個加載表單並加載其他表單
我該如何做到這一點?
這裏是加載方式的代碼:
public Loading()
{
InitializeComponent();
this.timer1.Interval = SystemManager.RandomNumberGenerator(1000, 2000);
this.timer1.Tick += new EventHandler(this.CheckTimer);
}
private void Loading_Load(object sender, EventArgs e)
{
this.timer1.Start();
}
private void CheckTimer(object sender, EventArgs e)
{
uint timeLeft = 1;
timeLeft--;
if (timeLeft == 0)
{
this.timer1.Stop();
this.Hide();
AgeConfirmation _ageConfirmation = new AgeConfirmation();
_ageConfirmation.ShowDialog();
this.Close();
}
}
上面的代碼是一個裝載形式和負載達到0.1
另一種形式的時候我已經試過這樣:
public class SystemManager
{
public static void LoadForm(Form _form = null, Form _loadForm = null)
{
_form.Hide();
_loadForm = new Form();
_loadForm.ShowDialog();
_form.Close();
}
}
並以如下方式訪問它:
SystemManager.LoadForm(this, AgeConfirmation);
但它引發以下錯誤:
'System.Windows.Forms.AgeConfirmation' is a 'type' but is used like a 'variable'
我的問題是:創建只有一種形式(載表),並獲得該期加載方式和時間,時間達到0,它將訪問不同的形式。
您的回答非常感謝!
非常感謝!
'if(timeLeft == 0)'在此代碼中始終爲真。 – BanksySan 2015-01-21 09:57:48