How can I delete the events using the system reflection?

G

Giò

Hi at all.
I have my personal button that inherits from system.windows.forms.button, in
this way

Public Class MyButton

Inherits System.Windows.Forms.Button

..

..

Private Sub MyButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Click

MsgBox("This is My Button Click")

End Sub

Private Sub MyButton_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.DoubleClick

MsgBox("This is My Button DoubleClick")

End Sub

Private Sub MyButton_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize

MsgBox("This is My Resize")

End Sub

End Class


In a form at runtime I create a button, using the system
reflection.assembly.createInstance method, and it works fine.
So, if I click on the created button, the message "This is My Button Click"
is sent.
If I do DoubleClick the message "This is My DoubleClick" is sent.... end so
on

Now i'd want create the instance of the button, removing all events at
runtime.
So, after the creation of the new button, the events would not have more
being raises.
(click, doubleclick ... don't send nothing)

How can I do, using reflection?


I would reall appreciate your help.

Thanks in advance
(sorry for my bat English)
Giò
 
C

Craig Vick [MSFT]

Hi Gio,

I don't think you can do this via reflection. What is your reason for using
reflection? Why not just New you're inherited button.

Craig VB .NET Team
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top