>> Private Sub ChildForm_Load(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MyBase.Load
>> ^^^^^^^^^^^^^^^^
>>
>> End Sub
Take that line of code out and add this:
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
' MyBase.OnLoad(e)
End Sub
Note the call to MyBase.OnLoad is commented out to prevent the invalid
handle issue. To prevent 40 instances of VS.NET popping up, add this to
Form1_Load:
Private Sub Form1_Load(...)
If Not DesignMode Then
Dim frm As New Form2()
frm.Show()
End If
End Sub
> Cerebrus,
> To clarify your one point, the inherited form also inherits the load
> event of the parent form? So, whenever the inherited form loads, it
[quoted text clipped - 36 lines]
>>
>> Cerebrus.
RYoung - 26 Feb 2006 22:26 GMT
Anyways, theres somthing cicular going on there.
If you comment out this:
> Protected Overrides Sub OnLoad(ByVal e As EventArgs)
> ' MyBase.OnLoad(e)
> End Sub
and put a breakpoint on Form1_Load, you'll see that method is called
repeatedly - hover the (sender As Object) parameter and you'll see the first
call is from Form1, the subsequent calls are from Form2. Overriding the
OnLoad method in Form2 and not calling MyBase.Load from it will prevent that
series of calls to the base form.
Ron
>>> Private Sub ChildForm_Load(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles MyBase.Load
[quoted text clipped - 61 lines]
>>>
>>> Cerebrus.
Cerebrus - 27 Feb 2006 06:48 GMT
RYoung and RSine,
I think your point is valid and should work. I haven't had the chance
to test it out yet, so I hope RSine will try it out and let us know if
it works.
As for the explanation as to why this happens :
1. 41 forms popping up even when in Design mode. (Is the Load event
triggered even in Design mode ??? I was under the impression that only
the Paint method is called.)
2. Why is the Load event of the Inherited Form called repeatedly ?
I leave these questions to the more experienced among us... ;-)
Regards,
Cerebrus.