Hi,

I have a little issue that I need some light shed on please.

I have 2 forms; StartUp and MainForm.

When the application starts with the StartUp form the forms load section check to see if a file exists, if it does, it closes and opens the MainForm using the code below:-

MainForm form = new MainForm();
			form.ShowDialog();
			this.Close();

That all works brilliantly and if the file does exist the application runs straight to the MainForm without showing the StartUp form at all.

However, I have been trying to implement this same piece of code onto a button click event on my StartUp form and this is where it breaks down.

Upon clicking the button, the MainForm loads fine but the StartUp form is still displayed albeit behind the MainForm.

What would be causing this to happen?

How can I rectify it so the StartUp form does actually close on this button click?

Kind regards..,

MT ;)

Recommended Answers

All 9 Replies

MainForm form = new MainForm();
form.ShowDialog();
this.hide();

think of it like this you tell R2D2 to call C3PO and do somthing, but as soon C3PO is called R2D2 shuts down without relaying the message?

make sense?

No ok here is a better solution.

http://www.youtube.com/watch?v=oHg5SJYRHA0

MainForm form = new MainForm();
form.ShowDialog();
this.hide();

think of it like this you tell R2D2 to call C3PO and do somthing, but as soon C3PO is called R2D2 shuts down without relaying the message?

make sense?

No ok here is a better solution.

http://www.youtube.com/watch?v=oHg5SJYRHA0

OK, what has Rick Astley got to do with it?

it's simple use this.hide();
or
this.dispose();

this.Hide();
this.dispose();

OK, what has Rick Astley got to do with it?

everything

this.Hide();
this.dispose();

Thanks for replying but I have tried it this way also and still the same result.

I have now found a work around though.

Kind regards..,

MT ;)

everything

Get a life!

Get a life!

comon dude just messin around.

Please post your solution, so you may help someone else.

I used

Application.Restart();

MT :)

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.