Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 206353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:38:18+00:00 2026-05-11T17:38:18+00:00

Ok, so I have a base class which declares the event StatusTextChanged . My

  • 0

Ok, so I have a base class which declares the event StatusTextChanged. My child class, of course cannot directly raise this event.

So I wind up with something like this (for simplicity sake):

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#, either way it works essentially the same.

edit: So after the responses, I’m at this in the base class, then just set 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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:38:18+00:00Added an answer on May 11, 2026 at 5:38 pm

    I would say that you are rather close to the recommeneded way (or at least the one I would recommend).

    I would make a few alterations to your code, given a choice:

    • Make StatusTextChanged Protected Overridable
    • Wrap StatusText in a custom EventArgs class
    • Change the StatusTextChanged declaration into Public Event StatusTextChanged As EventHandler(Of YourCustomEventArgs)

    The resulting code:

    The custom eventargs class:

    Public Class TextEventArgs
        Inherits EventArgs
    
        Private _text As String
    
        Public Sub New(ByVal text As String)
            _text = text
        End Sub
    
        Public ReadOnly Property Text() As String
            Get
                Return _text
            End Get
        End Property
    
    End Class
    

    The event implementation in your base class:

    Public Event StatusTextChanged As EventHandler(Of TextEventArgs)
    Protected Overridable Sub OnStatusTextChanged(ByVal e As TextEventArgs)
        RaiseEvent StatusTextChanged(Me, e)
    End Sub
    

    …and finally a code line for raising the event; either in the base class or a class that inherits it:

    OnStatusTextChanged(New TextEventArgs("some text"))
    

    This will be more in line with how events are designed within the rest of the .NET framework.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No you cannot use set, bag, list, idbag, or map… May 11, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer Since flex apps run on the flash runtime, you can't… May 11, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer From here: (wayback machine link) According to standard C++ (wayback… May 11, 2026 at 11:33 pm

Related Questions

Say I want to have a method that takes any kind of number, is
I feel like this is something I should already know, but I'm just not
I've been trying to solve this for ages (3 days) now and I just
Ok so I have an abstract base class called Product, a KitItem class that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.