我需要某种方式知道表单何时完成加载。我的理由是我有第二个表单,当这个表单加载时会加载。从 form1.load
调用此代码.Form2
当前显示在 form1
后面正如我所猜测的 form1
在加载结束时调用 activate 或类似的方法,因此任何 Activate、BringToFront 等都会调用 form2
被覆盖。
如果您查看下面的代码,我尝试添加 frmAllocationSearch.Activate
, frmAllocationSearch.BringToFront
和 Me.SendToBack
调用 ShowAlloactionSearchDialog()
后,但是这些都被浪费了,因为在加载事件被触发以带来 Me
之后发生了一些事情。到前面。
代码是:
Private Sub Allocation_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
ShowAlloactionSearchDialog()
End Sub
Private Sub ShowAlloactionSearchDialog()
If frmAllocationSearch Is Nothing OrElse frmAllocationSearch.IsDisposed Then
frmAllocationSearch = New AllocationSearch
frmAllocationSearch.MdiParent = Me.MdiParent
frmAllocationSearch.Info = Me.Info
frmAllocationSearch.Top = Me.Top
frmAllocationSearch.Left = Me.Left + Me.Width - frmAllocationSearch.Width
frmAllocationSearch.AllocationWindow = Me
frmAllocationSearch.Show()
Else
If frmAllocationSearch.WindowState = FormWindowState.Minimized Then
frmAllocationSearch.WindowState = FormWindowState.Normal
End IF
frmAllocationSearch.Activate()
End If
End Sub
最佳答案
也许你可以试试Form.Activated事件。
Occurs when the form is activated in code or by the user.
关于加载事件后的 VB.NET .NET?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2431797/