Ok, so I have a base class that declares an event StatusTextChanged. My child class, of course, cannot directly raise this event.
So, I am completing something like this (for simplicity):
Public MustInherit Class FooBase
Public Event StatusTextChanged(ByVal StatusText As String)
Protected Sub RaiseStatusTextChangedEvent(ByVal StatusText As String)
RaiseEvent StatusTextChanged(StatusText)
End Sub
End Class
And then in the child class I call
MyBase.RaiseStatusTextChangedEvent("something"). Is there a better or more recommended way to do this?
edit: VB.NET or C #, in any case, it works almost the same.
edit: So, after the answers, I am in this in the base class and then just setting the StatusText property in the child class ...
Public Event StatusTextChanged(ByVal StatusText As String)
Private _StatusText As String = "Idle."
Public Property StatusText() As String
Get
Return _StatusText
End Get
Protected Set(ByVal value As String)
RaiseEvent StatusTextChanged(value)
End Set
End Property
source
share