Solved

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

Posted on 2014-02-21
5
209 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now