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工作這麼好! –