当前位置 : 主页 > 编程语言 > c语言 >

加载事件后的VB.NET .NET?

来源:互联网 收集:自由互联 发布时间:2021-06-24
我需要一些方法来了解表单何时完成加载.我的理由是我有一个加载此表单时加载的第二个表单.从form1.load调用此代码. Form2当前正在form1后面显示,因为我猜测form1在加载结束时调用了act
我需要一些方法来了解表单何时完成加载.我的理由是我有一个加载此表单时加载的第二个表单.从form1.load调用此代码.

Form2当前正在form1后面显示,因为我猜测form1在加载结束时调用了activate或类似的东西,因此覆盖了form2上的任何Activate,BringToFront等调用.

如果你查看下面的代码,我已经尝试在调用ShowAlloactionSearchDialog()之后添加frmAllocationSearch.Activate,frmAllocationSearch.BringToFront和Me.SendToBack,但这些都被浪费了,因为在load事件被触发之后发生了一些事情前方.

代码是:

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.

网友评论