Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2014-02-21
5
212 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

792 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