Closing a form but keeping the information in the form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bjstone15
    New Member
    • Apr 2010
    • 4

    Closing a form but keeping the information in the form

    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?
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    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.

    Comment

    • bjstone15
      New Member
      • Apr 2010
      • 4

      #3
      I guess a web app

      Comment

      • bjstone15
        New Member
        • Apr 2010
        • 4

        #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.

        Comment

        • bjstone15
          New Member
          • Apr 2010
          • 4

          #5
          Hey! I figured it out, it's a Me.Dispose()

          Thanks for your help anyways!

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            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

            Comment

            Working...