假设我有一个对象(例如,Form1)的成员(例如,Button1),该对象(例如,Form1)是使用 withevents (例如,Form1.Button1_Click)定义的,并且该对象中有一个带有“Handles”的处理程序。
如果我覆盖它(例如,Form2.Button1_Click),处理程序将调用覆盖版本(如 me.Button1_Click)还是带有实际句柄的版本(如 MyClass.Button1_Click)?
这是我尝试过的:
Public Class Form1
Public Overridable Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("Form1's Button")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim f2 As New Form2
f2.Show()
End Sub
End Class
Public Class Form2
Inherits Form1
Public Overrides Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MsgBox("Form2's Button")
End Sub
End Class