是否可以通过属性访问器监听父类对象的事件?
我尝试过的(一个最小的例子):
Public Class ParentFoo
Private WithEvents m_bar As EventyObj
Public Property Bar() As EventyObj
Get
Return m_bar
End Get
Set(ByVal value As EventyObj)
m_bar = value
End Set
End Property
End Class
Public Class ChildFoo
Inherits ParentFoo
[...]
Public Sub Bar_OnShout() Handles Bar.Shout
' Some logic
End Sub
End Class
我收到的特定错误消息(VS2005)是“Handles 子句需要在包含类型或其基本类型之一中定义的 WithEvents 变量。” 通过公共属性访问私有 WithEvents 变量是否会去除“WithEvents”?