Eventhandler

K

Kalim Julia

I need to delegate function using addhandler.

AddHandler mlcmdDELETERECORD.Click, AddressOf DeleteGridRecordEvent



Public Overridable Function DeleteGridRecordEvent(ByVal sender As Object,
ByVal e As System.EventArgs) As Boolean

mlDELETERECORDALLOWED = MsgBox("Are you sure want to delete the record ?",
MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2) = MsgBoxResult.Yes

End Function

The error says :

Z:\Shared\CustomControl\CustomDataGrid\CustomDataGrid.vb(272): Method
'Public Overridable Function DeleteGridRecordEvent(sender As Object, e As
System.EventArgs) As Boolean' does not have the same signature as delegate
'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'.


Anybody can help ?
 
R

R. MacDonald

Hello, Kalim,

The delegate needs to be a "Sub" instead of a "Function".

Cheers,
Randy
 
C

Cerebrus

Hi,

As R. MacDonald said, your Delegate needs to be a Procedure instead of
a Function.

Make it simply :

Public Sub DeleteGridRecordEvent(ByVal sender As Object,
ByVal e As System.EventArgs)
:
:
End Sub

Since you wanted to return a Boolean value from this procedure, you can
instead declare a global Boolean variable, and update it's value in
this procedure. Then access it's value wherever needed.

HTH,

Regards,

Cerebrus.
 

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