无法将打开的表单带到前端/焦点vb.net

时间:2015-04-06 00:39:35

标签: vb.net winforms

您好我有五种表格,我想打开一个表格,如果它没有打开,如果它打开就会带到前面或焦点。我尝试过使用BringToFrontShowTopMost,但没有任何作用。

If Not Application.OpenForms.OfType(Of StudentRegistrationFrm).Any Then
        StudentRegistrationFrm.ShowDialog()
    Else
        StudentRegistrationFrm.BringToFront()
        'Me.SendToBack()
End If

1 个答案:

答案 0 :(得分:0)

我已经通过关闭当前表单解决了这个问题。

 If Not Application.OpenForms.OfType(Of StudentRegistrationFrm).Any Then
        StudentRegistrationFrm.Show()
    Else
        Me.Close()
    End If
   Private Sub StudentInformationToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles StudentInformationToolStripMenuItem.Click
    Dim studentReg As StudentInfoFrm = New StudentInfoFrm
    studentReg.Show()
    Me.Close()
 End Sub