S
Samuel R. Neff
Is there any way to create a generic event handler that can be
subscribed to any event? If I have a sub..
Private Sub DataTable_SomethingChanged(sender As Object, e As
System.EventArgs)
and subscribe it to
AddHandler dataTable.ColumnChanged, AddressOf SomethingChanged
it gives me this error
Method 'Private Sub DataTable_SomethingChanged(sender As Object, e As
System.EventArgs)' does not have the same signature as delegate
'Delegate Sub DataColumnChangeEventHandler(sender As Object, e As
System.Data.DataColumnChangeEventArgs)'.
Even though the signature doesn't match exactly, it is still
compatible. If it wasn't a delegate but just a regular method call I
could pass an instance of DataColumnChangeEventArgs to a variable
expecting EventArgs. But that appears no to be the case with
delegates.
Any work-around? What I want to do is have one function that listens
to several events and at this point it seems I need a separate
function for each since they need different signatures (I don't care
about the details at all, I just want to know the event was
triggered).
Thanks,
Sam
B-Line is now hiring one VB.NET developer for
WinForms + WebServices position with ASPX in future.
Seaking mid to senior level developer. For
information or to apply e-mail sam_blinex_com.
subscribed to any event? If I have a sub..
Private Sub DataTable_SomethingChanged(sender As Object, e As
System.EventArgs)
and subscribe it to
AddHandler dataTable.ColumnChanged, AddressOf SomethingChanged
it gives me this error
Method 'Private Sub DataTable_SomethingChanged(sender As Object, e As
System.EventArgs)' does not have the same signature as delegate
'Delegate Sub DataColumnChangeEventHandler(sender As Object, e As
System.Data.DataColumnChangeEventArgs)'.
Even though the signature doesn't match exactly, it is still
compatible. If it wasn't a delegate but just a regular method call I
could pass an instance of DataColumnChangeEventArgs to a variable
expecting EventArgs. But that appears no to be the case with
delegates.
Any work-around? What I want to do is have one function that listens
to several events and at this point it seems I need a separate
function for each since they need different signatures (I don't care
about the details at all, I just want to know the event was
triggered).
Thanks,
Sam
B-Line is now hiring one VB.NET developer for
WinForms + WebServices position with ASPX in future.
Seaking mid to senior level developer. For
information or to apply e-mail sam_blinex_com.