There are many friends who hope that the MDI child form is not repeated. If the child has been created, activate it, not another MDI child form, in fact, the mdichildren provided by C # can solve this Question, below, assume a TreeView control, click on the corresponding nodes above TreeView, create the MDI sub-form named this node, if the sub-form has been created, then activate it, displayed in all child forms The most in front. code show as below:
Private void TreeView_AFTERSELECT (Object Sender, System.Windows.Forms.TreeViewEventArgs E)
{
System.string str = treeView.selectedNode.text; // get the TEXT value of the corresponding TreeView node
Bool remark = true;
For (int i = 0; i IF (this.mdichildren [i] .name.equals (str)) / / View no identical MDI subform { THIS.MDICHILDREN [I] .activate (); // Subform has been created and activated REMARK = false; Break; } IF (remark) // Established, establish a child form { FORM2 TEMP_FORM = New Form2 (); TEMP_FORM.MDIPARENT = this; Temp_form.name = STR; TEMP_FORM.TEXT = STR; TEMP_FORM.SHOW (); } } If there are many forms (such as FORM2, FORM3, FORM4, etc.) To create, you can use a switch to judge which one is to create. Another way is to judge the handle of the child, see the related content of the "专 专" blog in 9CBS. It is not repeated here. You can also see another blog How to make the form not repeated http://blog.9cbs.net/tjvictor/archive/2007/01/18/1486420.aspx