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

  • Home
  • SEARCH
  • 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 4097028
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:07:16+00:00 2026-05-20T20:07:16+00:00

I have done a base form for my window app but not sure is

  • 0

I have done a base form for my window app but not sure is this correct or is there a better way to improve it.

My purpose:

  1. Simplify my code at UI form
  2. Create CRUD button to be inherited.

Question:

  1. How do I implement interface with the 4 button events at the UserForm.cs by right clicking the UserForm:BaseForm. Currently I have to manually write all 4 button event to override.

  2. My BaseForm seem to be empty. Can I put the messageBox.show("succcess") at my baseForm? Meaning to say that after run the UserForm.cs, it will run back to BaseForm. This can save up a few lines of code at userform.

  3. Should I put my logger at the baseForm too?

My baseForm.cs

public BaseForm()
{
    InitializeComponent();
}

public virtual void btnSave_Click(object sender, EventArgs e)
{

}

public virtual void btnDelete_Click(object sender, EventArgs e)
{

}

public virtual void btnNew_Click(object sender, EventArgs e)
{

}

public virtual void btnReset_Click(object sender, EventArgs e)
{

}

My UserForm.cs inherit baseForm

public override void btnSave_Click(object sender, EventArgs e)
{
    if (!IsValidated()) return;
    BindValueToObject();

    try
    {
        user.Add();
        bindingSource.Add(user);
        MessageBox.Show("Success");
    }
    catch(Exception ex)
    {
        MessageBox.Show("failed");
        Logger.Error(typeof(UserForm), ex.ToString());
        return;
    }
}
public override void btnDelete_Click(object sender, EventArgs e)
{
    base.btnDelete_Click(sender, e);
}
public override void btnNew_Click(object sender, EventArgs e)
{
    base.btnNew_Click(sender, e);
}
public override void btnReset_Click(object sender, EventArgs e)
{
    base.btnReset_Click(sender, e);
}
  • 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-20T20:07:17+00:00Added an answer on May 20, 2026 at 8:07 pm

    1 – At the moment the methods in your base form is declared as virtual. This means that it is optional for any derived classes to override the methods. Therefore you won’t be notified asking to override them. If this is your desired behavior then you will have to manually override the methods by either writing the code yourself or getting your IDE to generate the methods for you. However, if this is not the desired behavior and you would in fact like to force all derived classes to implement these methods, then you should declare them as abstract.

    2 – Any calls to those methods will trigger the overridden methods in the derived class (if it exists) and thus the code in your base class will never get executed. If you’re interested in both executing the code in the derived- and the base class then you should issue a call to the base method like this

    public override void btnReset_Click(object sender, EventArgs e)
    {
      // do form specific stuff here
      someButton.Text = String.Empty;      
    
      // then invoke base method
      base.btnReset_Click(sender, e);
    }
    

    3 – If you’re going to do general logging for the form, then putting it in the base class would be a good idea. However, remember always to invoke the base method call in any overridden method.

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

Sidebar

Related Questions

I have done jQuery and Ajax, but I am not able to get the
I have done Java and JSP programming in the past, but I am new
I have done a bit of testing on this myself (During the server side
I have done a bit of research into this and it seems that the
I have done a little Django development, but it has all been in a
I have done this: $ z() { echo 'hello world'; } How do I
I thought this would have done it... $rowfetch = $DBS->{Row}->GetCharValue(meetdays); $rowfetch = /[-]/gi; printline($rowfetch);
I could have sworn i have done this somewhere - im using 2.0 right
I'm trying to deploy my app to Heroku, I've done this before on my
I have done some searches looking for information about how to do logging with

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.