C# MDI Parent detect when MDI Child is closing?

前端 未结 6 1142
青春惊慌失措
青春惊慌失措 2021-01-18 10:18

I\'m attempting to detect, on the MDI parent, when my MDI child form closes, and react accordingly. The MDI parent shouldn\'t do anything until the MDI child closes. Here is

6条回答
  •  不思量自难忘°
    2021-01-18 10:53

    Why you are doing so many things when you can just invoke an event handler of MDI Parent to MDI Child?

    Suppose I want to do certain things when my child will be activated or deactivated. You just need to declare some event handlers of MDI Parent (as e.g. SetupToolStripMenu_PlantMasterRecipe) and mention some logic inside that what you want to do. By this way, you can control each object behaviour of MDI Child from MDI Parent.

    Here objB is my Child form and I am writing this code inside MDI Parent:

    objB.MdiParent = this;
    
    objB.Activated += SetupToolStripMenu_PlantMasterRecipe;
    
    objB.Deactivate += DisposeToolStripMenu;
    
    objB.Show();
    

提交回复
热议问题