Prevent duplicate MDI children forms

前端 未结 7 747
攒了一身酷
攒了一身酷 2020-12-09 11:47

Is there a way to prevent the opening of a certain form within an MDI container if that said form is already opened?

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 12:16

    This code work for me in vb.net

     

    For Each f As Form In Application.OpenForms If TypeOf f Is form_name Then f.Activate() f.WindowState = FormWindowState.Normal f.StartPosition = FormStartPosition.WindowsDefaultLocation f.WindowState = FormWindowState.Maximized

                Return
            End If    
        Next 
        form_name .MdiParent = Me
        form_name .Show()
    

提交回复
热议问题