Probably an intro question -> starting window over? calling form_load?

M

matthewtec

This may be something that is painfully easy and I'm just missing, or it
could be something that I should learn a bit more in order to do.

But, if I have a simple windows form application, with just one form with
basic buttons, labels, etc, [and a couple timer controls, which count down
the time they have to enter a string into a single line textbox].
At a point in this little app I want the user to be able to 'start over'.

I'm wondering two things:
1) Can I do this by somehow calling the original Form1_Load ?

2) Or, if this is generally frowned upon, should I simply go through
resetting everything and disregard the original Form1_Load [except for the
variables, properties, etc, that need to be set properly]?


I hope this makes sense... but my main question is whether #1 is something
that either can be done / is it something that is frowned upon being done.

I apologize for not being experienced enough to know, but hope that someone
has a moment to help me out.

Thanks
Matt
 
D

Dave Cowart

matthewtec said:
This may be something that is painfully easy and I'm just missing, or it
could be something that I should learn a bit more in order to do.

But, if I have a simple windows form application, with just one form with
basic buttons, labels, etc, [and a couple timer controls, which count down
the time they have to enter a string into a single line textbox].
At a point in this little app I want the user to be able to 'start over'.

I'm wondering two things:
1) Can I do this by somehow calling the original Form1_Load ?

2) Or, if this is generally frowned upon, should I simply go through
resetting everything and disregard the original Form1_Load [except for the
variables, properties, etc, that need to be set properly]?


I hope this makes sense... but my main question is whether #1 is something
that either can be done / is it something that is frowned upon being done.

I apologize for not being experienced enough to know, but hope that someone
has a moment to help me out.

Thanks
Matt
Calling the original Form1_Load isn't the same as reloading the form--it
just contains code to fire in response to the form loading. What I
usually do in a situation like that is have a Sub that resets all the
controls and whatnot to their original state.

Alternatively (and I've never tried this, nor do I think it's an elegant
solution), is to ope a tiny second form with its opacity set to 0 and
set to not show in the task bar, and have the Form2_Load close the
original Form1, reopen it, then close itself).

Like I said, that solution isn't your best bet, but it's an option.
 
C

Cor Ligthert [MVP]

Matthewtec,

we don't know if you use version 2002/2003 or version 2005. However go to
the designer generated part. (For 2005 you have first to set the option show
all files in the solution explorer).

Than open the plus of that. You see there a sub InitializeComponent

After that you have done me.controlcollection.clear you can use this method.

I hope this helps,

Cor
 
D

Dave Cowart

Cor said:
Matthewtec,

we don't know if you use version 2002/2003 or version 2005. However go to
the designer generated part. (For 2005 you have first to set the option show
all files in the solution explorer).

Than open the plus of that. You see there a sub InitializeComponent

After that you have done me.controlcollection.clear you can use this method.

I hope this helps,

Cor
I think what he's trying to do isn't to completely clear all of the
contents of his form, but to reset them to the state they were in when
the form was first loaded.
 
C

Cor Ligthert [MVP]

Dave,
I think what he's trying to do isn't to completely clear all of the
contents of his form, but to reset them to the state they were in when the
form was first loaded.

That is what I describe. (However for describing there is a slight
difference between the versions)

Cor
 
M

matthewtec

Cor and Dave --

Thanks -- from your posts I am able to figure out what I should do... before
getting your posts, I wasn't sure if I was supposed to be calling the
initial Form_Load or resetting everything myself.

So, your posts helped very much... many thanks.

[Also... I'm not sure if this is the information you're looking for, but in
Help/About, I have:
Microsoft Development Environment 2003
Microsoft .NET Framework 1.1
]

Thanks.
matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top