0
我将使用属性来保留click子地址,然后将其分配给AddRow()子中的每个按钮。出现问题时,我得到了以下错误:保留属性中的子地址
错误1
Method 'Public Property ClickEvent As Button_Click' does not have a signature compatible with delegate 'Delegate Sub EventHandler(sender As Object, e As 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
Thanks.It工作这么好! –