Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

What to do with a windows form after the data has been saved in vb.net

Posted on 2014-02-21
5
Medium Priority
?
217 Views
Last Modified: 2014-02-21
Hi all.

I just finished a windows form in Visual Studio 2010 and now I'm wondering how can I clear everything and open the form again.

After the data is saved I'm going to ask them "Do you want to submit another item?". If they say no then I'll close the form, but if they say yes then how can I reopen the form to it's initial state.

Thank you in advance.
0
Comment
Question by:printmedia
  • 4
5 Comments
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 39877134
If you just have a bunch of textboxes then you can:
for each c as control on me.controls 
  if typeof(c) is texbox then
    directcast(c, textbox).clear
  end if
next

Open in new window

0
 

Author Comment

by:printmedia
ID: 39877151
Thanks! I also have 2 datagridview controls that have data based on what is entered in some of the text boxes. How do I clear the datagrids?
0
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 39877155
I'd put this in a "Initialize" subroutine (call it whatever you want) and call that when loading the form...then later you can just call that subroutine whenever you need to clear the form.
0
 
LVL 15

Accepted Solution

by:
David L. Hansen earned 2000 total points
ID: 39877163
directcast(c, datagridview).rows.clear

OR

if you are using the datasource property of the grid, just set the datasource = nothing
0
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 39877359
Thanks!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question