2012-10-11 67 views

回答

4

這是弗雷德裏克·莫克的代碼VB.Net版本:

For Each f As Form In Application.OpenForms 
    If TypeOf f Is Form1 Then 
    f.Activate() 
    Return 
    End If 
Next 

Dim myChild As New Form1 
myChild.MdiParent = Me 
myChild.Show() 
1

試試這個

private void button1_Click(object sender, EventArgs e) 
{ 
    FormCollection fc = Application.OpenForms; 
    bool FormFound = false; 
    foreach (Form frm in fc) 
    { 
     if (frm.Name == "Form2") 
     { 
      frm.Focus(); 
      FormFound = true; 
     } 
    } 

    if (FormFound == false) 
    { 
     Form2 f = new Form2(); 
     f.Show(); 
    } 
}