I have the following code that creates a button :
Dim B As New Button
B.Parent = Me
B.Location = New Point(50, 50)
AddHandler B.Click, Sub()
MsgBox("Hi")
End Sub
'I try to get the field info for the click event inorder to get the event handler and remove it
Dim FieldInfo As FieldInfo = B.GetType.GetField("Click", BindingFlags.[Static] Or BindingFlags.NonPublic Or BindingFlags.Public)
Dim obj As Object = FieldInfo.GetValue(Obj_)
Dim EI As EventInfo = Obj_.GetType.GetEvent(EventName)
EI.RemoveEventHandler(Obj_, obj)
but the FieldInfo is constantly null. I tried with many event names ClickEvent, EventClick... but none of them allowed me to get a result.
Does anyone know what is missing to my code please ?
Thank you in advance.