私は MDIParent と Menustrip を持っているので、StripMenuitem をクリックすると、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();
}
}
したがって、子 Form 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");
}