我这里有一些代码,要求用户先关闭之前打开的窗口再打开另一个窗口,或者告诉用户他要打开的窗口已经打开。我希望打开的表单保持打开状态,并且在打开时不会最小化。
Private Sub FindClientToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FindClientToolStripMenuItem.Click
'Close items form
Dim Close_items As New Form_items
'Call find client form when clicking tab Find client
Dim ShowFindClient As New Find_Client
'If the find_items form or window is opened, then a message prompts the user to close it first
If Application.OpenForms().OfType(Of Form_items).Any Then
playErrorSound()
MsgBox("Close Find_items window first", MsgBoxStyle.OkOnly, "MDCS")
'If find_clients form is opened. the user can not open it twice.
ElseIf Application.OpenForms().OfType(Of Find_Client).Any Then
playErrorSound()
MsgBox("The Window is already opened", MsgBoxStyle.OkOnly, "MDCS")
Else
'If the find_client window is not opened, it opens.
ShowFindClient.Show()
End If
End Sub
Me.MinimizeBox = False
在您的条件下使用时,可以按如下所示在表单加载中将其禁用:
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MinimizeBox = False
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句