Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / November 2005

Tip: Looking for answers? Try searching our database.

reset a unbound form after a record deletion

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stephen - 25 Nov 2005 13:55 GMT
I am using Visual C# Express (.net 2.0) and I am wondering if there is
a way to reset a form.  I come from asp.net and I am used to binding
the data in code during the page load event.  Winforms offers
databinding more like ms access, where you can bind the form directly
to a dataset, but I prefer unbound forms.  In asp.net, when a user
deletes a record on a webform for instance, I simple redirected them to
the same form after a little javascript prompt to validate the
deletion.  This produces a blank form again.  Is there anyway I can
reproduce this behavior in winforms without having to cycle through all
the controls on the form and reset the values?  I looked at a couple
options.  One was to just close the form after the deletion; another,
although I am not sure if this is a good way, was to open a new
instance of the same form and close the other.  My main concern is if I
add a new control to a form down the road I have to remember to add it
to the clear method also.
Bart Mermuys - 25 Nov 2005 14:25 GMT
Hi,

>I am using Visual C# Express (.net 2.0) and I am wondering if there is
> a way to reset a form.  I come from asp.net and I am used to binding
> the data in code during the page load event.  Winforms offers
> databinding more like ms access, where you can bind the form directly
> to a dataset, but I prefer unbound forms.

To be more exact, one usually binds a DataSet, DataTable or DataView to
individual Controls, not to the Form itself.

> In asp.net, when a user deletes a record on a webform for instance, I
> simple
[quoted text clipped - 8 lines]
> add a new control to a form down the road I have to remember to add it
> to the clear method also.

I don't believe there is a way to reset all Controls.

I would choose between making a ClearFields method and clear all controls
individually or cycling though the Controls collection and clearing them.  I
wouldn't close and re-open the Form.

HTH,
greetings

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.