When I visited the 9CBS forum at night, I saw a friend in the C # district asked "Preventing the MDI Son Form", I immediately wrote this article. In fact, this problem is the single-piece mode in the classic 23 design model. The following uses C # implementation: First of all, we have 2 Windows Form, the main form is called Form1, the sub-form called ChildForm. Add a menu to the main form, use to instantiate the subform, we write the following code in Form1.cs: private static childform childform; // Static variable, save the unique instance private void menuitem2_click (Object Sender, System. Eventargs e) {childform childform = getChildForm (); // Get child form object child.show (); // Display}
Private childForm getChildForm () {// Successful order can not be wrong, the previous condition is used to determine if it is the first time, the latter condition is used to determine if the child has been turned off if (childform == null || childform.isposed) {// The first instantiation is also, it is closed, and it is also re-instantiated ChildForm = new childform (); childform.mdiparent = this;} return childform;} ----------- -------------------------------------------------- -------------------------------------------- OK, Just Easy Like This! Enjoy it! On January 6, 2005, Zhang Yuxiang