Home All Groups Group Topic Archive Search About

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

Author
12 Jan 2006 5:26 AM
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

Author
12 Jan 2006 6:16 AM
Dave Cowart
matthewtec wrote:
Show quoteHide quote
> 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.
Author
12 Jan 2006 6:21 AM
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
Author
12 Jan 2006 6:25 AM
Dave Cowart
Cor Ligthert [MVP] wrote:
Show quoteHide quote
> 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.
Author
12 Jan 2006 6:46 AM
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
Author
12 Jan 2006 8:40 PM
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

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:OHWYmP0FGHA.2084@TK2MSFTNGP09.phx.gbl...
> 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
>