I have no idea why i get bombarded with Inferior Small irritating bugs....

uh... Please help this poor, Form struggling guy.


To simplify, i have 2 forms. FormA and FormB. At startup, FormA is displayed now i would like to go to FormB. I use this and it works.

FormB frmQseScorecard = new FormB();
            this.Visible = false;
            frmQseScorecard.ShowDialog();
            this.Dispose();

Now from FormB i want to go back to FormA thus i use the same method

FormA frmQseScorecard = new FormA();
            this.Visible = false;
            frmQseScorecard.ShowDialog();
            this.Dispose();

Now from FormA i want to exit. But when i click the close button "the X on the top right" It closes FormA, but opens It again. Then after another click of the close button in only closes. (Depending on how many times i jump from formA to FormB before closing is the amount of times i must click close to close it...)

No idea how to fix this bug, for i have created a simple program to test this, and it works fine. But in my project it does not want to work..
I attached a prototype so you can see what it does, and that im not starting to lose my mind... Coz i cant see anything wrong with the code..

Thanks for any help on this strange Bug

Ruan

Recommended Answers

All 6 Replies

ShowDialog shows the form as a modal dialog.
I think you better use the Show method here.

i dont think the problem is Show(), after looking at your code you are creating two instnace of FormA, the first one is when your app starts and the second one is when you wants to return to FormA from FormB.
What you need to do is:

FormB frmB = new FormB();
this.Hide();
frmB.ShowDialog();
this.Show();

When the user will close frmB it will return to FormA and will show it self.

i dont think the problem is Show(), after looking at your code you are creating two instnace of FormA, the first one is when your app starts and the second one is when you wants to return to FormA from FormB.
What you need to do is:

FormB frmB = new FormB();
this.Hide();
frmB.ShowDialog();
this.Show();

When the user will close frmB it will return to FormA and will show it self.

I figured it out, but still have no idea why it would work now. what i did was

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
            //Main thismain = new Main();
            //this.Visible = false;
            //thismain.ShowDialog();
            //this.Dispose();
        }

And i deleted the exit form method. then it worked. No clue why though. but hey. guess you dont always know why stuff work??

You solve it in a bad way, bceause like i said before you are openning two instances of the same form.
Try to understand what i said and implement it.
Enjoy.

um.. But in your code, you also create a new form, and instead of closing it, you hide it. Why my solution worked is because the form closing event is called right before the form closes, and in the formcloses i showed the main menu again.
I checked it with the debugger and another pc, it works fine.

But thanx alot. =)

You are completly wrong, but OK.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.