Lumpi Lumpi - 7 months ago 17
Vb.net Question

How to use the Show Event in VB.net

I try tu use this msdn snipped to execute some code right after my form loads:

Private Sub Form1_Shown(sender as Object, e as EventArgs) _
Handles Form1.Shown
Some Code
End Sub


But it seems that I am missing something. I get an errormessage that translated sounds like this:

The Handle requiere an WithEvents-Variable, which is defined in the contained type or its basis class... My Form is named Form1 so that should be ok. the error is marked in the second line of the code. Any ideas?

Answer

Instead of:

Handles Form1.Shown

do this:

Handles Me.Shown