By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,880 Members | 2,292 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,880 IT Pros & Developers. It's quick & easy.

Eventhandler

P: n/a
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\CustomDataG rid.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 ?
Feb 28 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello, Kalim,

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

Cheers,
Randy
Kalim Julia wrote:
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\CustomDataG rid.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 ?

Feb 28 '06 #2

P: n/a
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.

Feb 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.