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

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.
printmediaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
David L. HansenConnect With a Mentor Programmer AnalystCommented:
directcast(c, datagridview).rows.clear

OR

if you are using the datasource property of the grid, just set the datasource = nothing
0
 
David L. HansenProgrammer AnalystCommented:
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
 
printmediaAuthor Commented:
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
 
David L. HansenProgrammer AnalystCommented:
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
 
David L. HansenProgrammer AnalystCommented:
Thanks!
0
All Courses

From novice to tech pro — start learning today.