Jos*_*oie 1 vb.net asp.net event-handling
我有一段代码:
innerchannel.Closing += Function(sender, e)
RaiseEvent Closing(sender, e)
End Function
Run Code Online (Sandbox Code Playgroud)
有一个问题
innerchannel.Closing
Run Code Online (Sandbox Code Playgroud)
VisualStudio告诉我:
Public Event Closing(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
Run Code Online (Sandbox Code Playgroud)
如何修复此工作?
我假设您要为Closing-event添加处理程序:
AddHandler innerchannel.Closing, AddressOf Closed
Run Code Online (Sandbox Code Playgroud)
如果要引发自定义事件,例如UserControl
:
Class Channel
Inherits UserControl
Public Event Closing(ch As Channel)
' this could be for example a button-click handler
Protected Sub Closed(sender As Object, e As System.EventArgs)
RaiseEvent Closing(Me)
End Sub
End Class
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4014 次 |
最近记录: |