VB.NET .NET after load event?
Solution 1
Maybe you can try the Form.Activated event.
Occurs when the form is activated in code or by the user.
Solution 2
You may want to try the Forms 'Shown' Event
themaninthesuitcase
Updated on June 09, 2022Comments
-
themaninthesuitcase almost 2 years
I need some way of knowing when a form has finished loading. My reasoning is I have a second form that is loaded when this form loads. The code for this is called from
form1.load
.Form2
is currently being displayed behindform1
as I am guessingform1
calls an activate or similar at the end of the load so any Activate, BringToFront, etc. calls onform2
are overridden.If you look at the code below, I have tried adding
frmAllocationSearch.Activate
,frmAllocationSearch.BringToFront
andMe.SendToBack
after the call toShowAlloactionSearchDialog()
, but these are all wasted as something is happening after the load event is fired to bringMe
to the front.The code is:
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
-
themaninthesuitcase about 14 yearsI had to add a flag to prevent it being on top all the time but this was perfect.
-
htm11h about 8 yearsThis event is still in the initialization process. The Form is not fully loaded when this event is called.