Question

I have a principal form that contains a menu to open child form:

public Le_MainForm()
{ 
  InitializeComponent();
  this.IsMdiContainer = true;
  .....
}

private void barButtonItem_CreatOrdreAller_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
  Close_AllForm();
  Program.StatusOrdre = 1;
  Program.AllerRetour = "Ordre Aller";
  Fiche_Ordre f_Fiche = new Fiche_Ordre();
  f_Fiche.MdiParent = this;
  f_Fiche.Show();
}

It works well, but I open another form from child, I lost MdiParent:

public Liste_Ordres()
{
  InitializeComponent();
  ....
}

private void Liste_DobleClic(object sender, EventArgs e)
{
  Fiche_Ordre f_Fiche = new Fiche_Ordre(gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString());
  f_Fiche.ShowDialog();
}
Was it helpful?

Solution

Try setting the form like this:

Fiche_Ordre f_Fiche = new Fiche_Ordre(gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString());
f_Fiche.MdiParent = this.MdiParent;
f_Fiche.Show();

ShowDialog() is for a pop-up modal form.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top