By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,714 Members | 1,182 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,714 IT Pros & Developers. It's quick & easy.

Closing a form but keeping the information in the form

P: 4
I am working on a project that has the user building scrapbook pages through several different forms. When the user selects something a presses a button I have the information about the selection load to a list box which is on a CheckoutForm. One of the options I have is for the user to save what they have made (this includes the information in the list boxes) and return to a previous form to build another page. I have been trying to use the Me.Close() but it does not save the information and using Me.Hide() displays the wrong elements on the forms. Any ideas of how to get around this?
Apr 28 '10 #1
Share this Question
Share on Google+
5 Replies


yarbrough40
100+
P: 320
is this a desktop app you are building or a web based app? because this approach will not work in a web app because web apps are stateless.
Apr 28 '10 #2

P: 4
I guess a web app
Apr 28 '10 #3

P: 4
I think is has to do something with the form just being hidden, so I have been trying a Me.Refresh but with little success.
Apr 28 '10 #4

P: 4
Hey! I figured it out, it's a Me.Dispose()

Thanks for your help anyways!
Apr 28 '10 #5

Frinavale
Expert Mod 5K+
P: 9,731
I'm glad you solved your problem...

A Web Application does not use Windows Forms.
There is no "Form.Hide()" method in web applications.
I find it very very strange that you didn't know what type of application you were developing.

The other thing is that the Dispose method is used for cleaning up any resources that the object uses. You aren't supposed to be doing any sort of "saving" in the dispose method because it isn't meant for this purpose....it's supposed to clean up resources like database connections etc.

A better solution would have been to have an exit button on the page (disable the X in the corner)...
  • You would create a custom class used to contain the information gathered on the form.
  • You would create a custom EventArgs class that would have a property that takes the custom class I mentioned above.
  • You would raise an event in the "exit button" code that would indicate that the form is closing.
  • You would use the custom EventArgs class to pass the custom class containing the information as the "e" parameter when you raised the event.
  • You would handle the custom event thrown in the parent page..where you could retrieve the custom object containing the information gathered on the form.

-Frinny
May 4 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.