how to reset the form

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2009
Posts: 143
Reputation: babbu has a little shameless behaviour in the past 
Solved Threads: 14
babbu babbu is offline Offline
Junior Poster

how to reset the form

 
0
  #1
Sep 6th, 2009
hie
if the user, after working with the form wishes to reset it, how can it be done.
will me.refresh() help.
wht is it used for?
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 54
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: how to reset the form

 
0
  #2
Sep 6th, 2009
no. me.refresh will just update
its actually depends on what exactlly you wish to reset like textboxes, checkboxes and so on.
you could do an function like:
  1. private sub ClearCtrl
  2. for each ctrl as control in Form1
  3. try
  4. if typeof(ctrl) is checkbox then ctrl.checked=false
  5. if typeof(ctrl) is textbox then ctrl.clear
  6. catch as exception
  7. 'catch the containers here
  8. end try
  9. next
end sub

something like that
Last edited by GeekByChoiCe; Sep 6th, 2009 at 2:27 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,721
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 500
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: how to reset the form

 
0
  #3
Sep 6th, 2009
I don't get a word "reset". Do you want to reset the state of controls or just clear the text or setting up selectedindex with 0?

  1. For Each c As Control In Me.Controls
  2. If TypeOf c Is TextBox Then
  3. CType(c, TextBox).Text = String.Empty
  4. End If
  5. Next
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 54
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: how to reset the form

 
-1
  #4
Sep 6th, 2009
oi sry i just saw i missed something
it should be "for each ctrl as control in Form1.controls"
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 54
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: how to reset the form

 
0
  #5
Sep 6th, 2009
cant edit my post anymore. but since adatapost told me its not working i did a test and its working

  1. For Each ctrl As Control In Me.Controls
  2. Try
  3. If TypeOf (ctrl) Is CheckBox Then DirectCast(ctrl, CheckBox).Checked = False
  4. If TypeOf (ctrl) Is TextBox Then DirectCast(ctrl, TextBox).Clear()
  5. Catch ex As Exception
  6. 'catch the containers here
  7. End Try
  8. Next

works as it is and only if you dont have the controls inside containers such as panels, groupboxes then you need to recurse these aswell.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,721
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 500
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: how to reset the form

 
0
  #6
Sep 6th, 2009
@GeekByChoice : it should be "for each ctrl as control in Form1.controls".
-- It must be Me.Controls.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 54
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: how to reset the form

 
0
  #7
Sep 6th, 2009
yeye take it easy man. i was sure the user can figure that out by himself. but anyway u r right
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 40
Reputation: Arunabh Nag is an unknown quantity at this point 
Solved Threads: 1
Arunabh Nag's Avatar
Arunabh Nag Arunabh Nag is offline Offline
Light Poster

Re: how to reset the form

 
0
  #8
Sep 6th, 2009
isn't there a centralised option for resetting the from...

like am using a user specified array of custom controls on a flow panel connecting to a database.

Now how do i reset the data to it's initial state if the user presses a button called reset
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,411
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 613
Sponsor
sknake's Avatar
sknake sknake is online now Online
.NET Enthusiast

Re: how to reset the form

 
0
  #9
Sep 6th, 2009
Dispose the form and re-instantiate it to the state defined by the contructor(s). However I am almost certain this is not what you want so please clarify what you are doing, and what you would like to do.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC