VB.NET.NET after load event?

I need a way to find out when the form has finished loading. My reasoning: I have a second form that loads when this form loads. The code for this is called from form1.load .

Form2 is currently displayed behind form1 , since I assume that form1 triggers an activation or similar at the end of the load, so any Activate, BringToFront, etc. Form2 calls are redefined.

If you look at the code below, I tried to add frmAllocationSearch.Activate , frmAllocationSearch.BringToFront and Me.SendToBack after calling ShowAlloactionSearchDialog() , but they were all wasted, because something happens after the load event is fired transfer Me to Start.

The code:

 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 
+4
source share
3 answers

Perhaps you can try the Form.Activated event.

Occurs when a form is activated in code or by a user.

+3
source

You might want to try the Event shown in the form

+3
source

You can use the timer to slow down the function. Enable the timer during development and disable it during the first execution of the timer.tick event. Set interval to 500 for a comfortable delayed start.

Or you can directly use the Form.Shown event, but it will start immediately without any delay.

0
source

Source: https://habr.com/ru/post/1303918/


All Articles