我有一個MDIParent和一個Menustrip,所以當我點擊一個StripMenuitem時,顯示了我的另一個窗體,我的MdiParent窗體, 所以我的問題是:Form_Load事件在MdiParent裏面打開的窗體不會工作!,似乎我不得不使用另一個事件:/MdiParent中的Form_Load事件
任何想法? 謝謝
這裏是我的代碼是如何顯示的MdiParent形式
FormVehicule FV;
private void véhiculeToolStripMenuItem_Click(object sender, EventArgs e)
{
if (FV == null)
{
FV = new FormVehicule();
FV.MdiParent = this;
FV.WindowState = FormWindowState.Maximized;
FV.Show();
}
else
{
FV.WindowState = FormWindowState.Maximized;
FV.Show();
FV.BringToFront();
}
}
所以在子窗體FormVehicule
private void FormVehicule_Load(object sender, EventArgs e)
{
comboBoxUnite.SelectedIndex = 0;
U = new Unite(FormLogin.Con);
U.Lister();
for (int i = 0; i < U.C.Dt.Rows.Count; i++)
comboBoxUnite.Items.Add(U.C.Dt.Rows[i][0].ToString());
comboBoxConducteur.SelectedIndex = 0;
C = new Conducteur(FormLogin.Con);
C.Lister();
for (int i = 0; i < C.C.Dt.Rows.Count; i++)
comboBoxConducteur.Items.Add(C.C.Dt.Rows[i][0].ToString());
V = new Vehicule(FormLogin.Con);
V.Lister();
dataGridViewVehicule.DataSource = V.C.Dt;
MessageBox.Show("Test");
}
您可以加入一些代碼片段?技術上,如果你使用'WinForm.Show()',它應該在技術上觸發'Form_Load'事件 – Alexandre 2012-02-17 14:52:27
你想調用Form_Load事件.. ??如果是這樣,只是把事件名稱(發件人,電子),如果這是你在說什麼,否則改寫你的問題,使其更清晰 – MethodMan 2012-02-17 14:55:35
現在,這裏是代碼:) – Obama 2012-02-17 14:56:32