473,324 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Reset a form?

If you have a form with multiple controls e.g. radio buttons, checkboxes,
etc., is there a way that you can reset the entire form to its original
state, other than setting an instance of the form to "Nothing" then
redeclaring it? Thanks.
Nov 21 '05 #1
4 14945
You may use a For Each.. statement to loop/reset the controls on the form.
"Martin Williams" <ma*******@comcast.net> wrote in message
news:2I********************@comcast.com...
If you have a form with multiple controls e.g. radio buttons, checkboxes,
etc., is there a way that you can reset the entire form to its original
state, other than setting an instance of the form to "Nothing" then
redeclaring it? Thanks.

Nov 21 '05 #2
The best way to do this is to make an Initization function that you call
from Sub New. Put in there all the code to load the form insted of doing it
through the designer (which puts in into InitializeComponent). Then you
will have a function you can call to reset your own form.

Chris

"Martin Williams" <ma*******@comcast.net> wrote in message
news:2I********************@comcast.com...
If you have a form with multiple controls e.g. radio buttons, checkboxes,
etc., is there a way that you can reset the entire form to its original
state, other than setting an instance of the form to "Nothing" then
redeclaring it? Thanks.

Nov 21 '05 #3
Duh, I don't know where my brain is sometimes..

Thanks!

"Mike McIntyre [MVP]" <mi****@getdotnetcode.com> wrote in message
news:eW**************@TK2MSFTNGP14.phx.gbl...
You may use a For Each.. statement to loop/reset the controls on the form.
"Martin Williams" <ma*******@comcast.net> wrote in message
news:2I********************@comcast.com...
If you have a form with multiple controls e.g. radio buttons, checkboxes, etc., is there a way that you can reset the entire form to its original
state, other than setting an instance of the form to "Nothing" then
redeclaring it? Thanks.


Nov 21 '05 #4
"Martin Williams" <ma*******@comcast.net> schrieb:
If you have a form with multiple controls e.g. radio buttons, checkboxes,
etc., is there a way that you can reset the entire form to its original
state, other than setting an instance of the form to "Nothing" then
redeclaring it?


Quick and dirty: Clear the form's 'Controls' collection and re-populate it
by calling the form's 'Sub InitializeComponent'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ken | last post by:
How can I reset the initial form variables that are set with session statements when clicking on a button? I tried this but the function was not called: <?PHP function reset_form($none) {...
2
by: Charles M. Fish, Sr. | last post by:
I’m so tired from banging this problem around all day, I hope I can explain it succinctly & accurately. I want to execute a function immediately following a click on <input type="RESET"... ...
2
by: Colin McKinnon | last post by:
Hi all, I've got two frames, one with a form ('main') and one with some clickable images ('tp'). The clickable images call a function in 'main' (code below) which in turn calls the .submit() or...
4
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label...
2
by: Lance | last post by:
I want to be able to reset a complex property in a PropertyGrid. I know that for properties that are ValueTypes you can include System.ComponentModel.DefaultValue in the declaration of the property....
2
by: Roger Withnell | last post by:
I need to reset a form to its original value using onclick rather than the Reset button. So, I have: <input type="button" name="reset" id="reset" value="Reset" onclick="form1.reset();"> where...
16
by: sreemati | last post by:
Hi everyone, This is the scenario: I have two button - Submit and Reset Submit is used for validation and after validation is passed it passes it to another form to enter into database. ...
11
by: newbie | last post by:
i have a form in which a hidden field (initial value as '0', and my javascript set it to '1' when an event is trigged). In the same form, i have a reset field. But I realized that the hidden field...
16
by: Giovanni D'Ascola | last post by:
Hi. I noticed that <input type="reset"actually don't enable checkbutton which are checked by default after they have been disabled by javascript. It's a bug?
3
by: artev | last post by:
if in a page I have a search form and I want use the method reset() for reinsert the default values, I notice that after a research, for the method reset(), the default values aren't more that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.