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 6688073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:21:44+00:00 2026-05-26T05:21:44+00:00

I have a base class (itself inheriting from Panel) and an inherited class. The

  • 0

I have a base class (itself inheriting from Panel) and an inherited class. The base class has a Click event-handler.

What is the correct way to make a Click event-handler in the inherited class fire before the base’s handler, and only then execute the base’s?

My workaround is of the following form:

class first : Panel
{
    public first()
    {
        Click += first_Click;
    }

    protected virtual void first_Click(object sender, EventArgs e)
    {
        doHandler();
    }

    protected void doHandler()
    {
        MessageBox.Show("first");
    }
}

class derived : first
{
    protected override void first_Click(object sender, EventArgs e)
    {
        MessageBox.Show("derived");
        doHandler();
    }
}

Is there a straightforward way?

Thanks.

  • 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-26T05:21:44+00:00Added an answer on May 26, 2026 at 5:21 am

    There’s no point in listening for your own events. Override the OnClick() method instead.

    class derived : first
    {
        protected override void OnClick(EventArgs e)
        {
            MessageBox.Show("derived");
            base.OnClick(e);
        }
    }
    

    Or call base.OnClick() first to alter the order.

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

Sidebar

Related Questions

I have a base class that initializes itself from a nib file. How can
I have a base class that has a private static member: class Base {
I have a base class for many tests that has some helper methods they
I have a base class called SpriteSheet which has two children, RotatedSpriteSheet and FlippedSpriteSheet.
I have a class called XorIsoStoreFileStream inheriting from IsolatedStorageFileStream, and the point is that
I have a class that inherits from a base class and implements the following...
I have base class BaseClass and derived classes DerivedA , DerivedB , and DerivedC
I have an interface with several events I have base class implementing the interface
I have a base class object array into which I have typecasted many different
I have a base class with an optional virtual function class Base { virtual

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.