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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:15:19+00:00 2026-05-18T10:15:19+00:00

I am working on a personal project in winforms just to gain some experience

  • 0

I am working on a personal project in winforms just to gain some experience in it since I’ve never had the chance to work with it before. So, I’m quite the n00b when it comes to Winforms. This is the error I’m encountering:

In form BudgetTracker, I have a button called ‘AddCat’. Below is the form’s constructor and the button’s click eventHandler:

        public form_BudgetTracker()
        {
            InitializeComponent();
            setEvents();
        }

        public void setEvents()
        {
            this.btn_AddCat.Click += new System.EventHandler(this.btn_AddCat_Click);
        }

        private void btn_AddCat_Click(object sender, EventArgs e)
        {
            form_NewCat NewCatForm = new form_NewCat();
            var NewCatFormResult = NewCatForm.ShowDialog();
            NewCatForm.Show();
        }

In the NewCat form that comes up, I have a Cancel button. Code:

        public form_NewCat()
        {
            InitializeComponent();
            SetEvents();
        }

        private void SetEvents()
        {
            this.btn_Add.Click += new System.EventHandler(this.btn_Add_Click);
            this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click);
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

The problem I’m facing is, when I click Add, the new form comes up. At this point, if I click Cancel, the form disappears but instantly a new instance of the form appears. I then click cancel again, and the form disappears.
What part of my code is making the form appear twice. I checked the contructors etc, but couldn’t figure it out. Any help or pointers would be appreciated.

PS – As I mentioned, I’m new to winforms programming, so any cues or pointers would be appreciated as well.

  • 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-18T10:15:20+00:00Added an answer on May 18, 2026 at 10:15 am
    private void btn_AddCat_Click(object sender, EventArgs e)
    {
        form_NewCat NewCatForm = new form_NewCat();
        var NewCatFormResult = NewCatForm.ShowDialog(); // <-- opens the first time
        NewCatForm.Show();                              // <-- opens the second time
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a personal project (C# / ASP.NET) that will use LINQ to
I'm working on database designs for a project management system as personal project and
I've started working on a fairly complicated software. It is for a personal project,
I am working on a personal project as a way of learning more about
I'm working on personal project which is basically a code editor. Imagine standard File
While working on a personal project I wanted a simple service to extract items
I'm working on a personal project and I'd love to be able to say
I am working on a personal project and although I do have a wiki
I'm working on a personal project and at the same time experimenting with it.
I'm working on a personal project to auto fill out the USPS Click &

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.