【发布时间】:2016-07-30 14:25:33
【问题描述】:
我将使用属性来保存单击子的地址,然后将其分配给 AddRow() 子中的每个按钮。当我收到以下错误时出现问题:
错误 1
方法 'Public Property ClickEvent As Button_Click' 没有 签名兼容委托“委托子事件处理程序(发件人 作为对象,e 作为 System.EventArgs)'。
Private Sub Button_Click(sender As Object, e As EventArgs)
'do somthing
End Sub
Class CustomClass
Public Fields As New List(Of FieldsDefinition)()
Class FieldsDefinition
Public Delegate Sub Button_Click(sender As System.Object, e As System.EventArgs)
Public __ClickEventValue As Button_Click
Public Property ClickEvent() As Button_Click
Get
Return __ClickEventValue
End Get
Set(ByVal value As Button_Click)
__ClickEventValue = value
End Set
End Property
End Class
Public Sub AddRow()
For Each field As FieldsDefinition In Fields
Dim ctrl As New TextBox
AddHandler ctrl.Click, AddressOf field.ClickEvent
Next
End Sub
End Class
【问题讨论】:
标签: .net vb.net properties delegates