Error calling a form that has been Closed with this.Close();

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fuzz13
    New Member
    • Jun 2010
    • 110

    Error calling a form that has been Closed with this.Close();

    I have a program that uses a custom message box. There is only the OK button on it which I originally coded with:
    Code:
    this.close();
    but then if I ever tried to load the message box again it said "can not access disposed form".

    I then set it instead to just hide the form when the ok button was clicked, which works, but I am not sure if it is running unnecessary resources?

    Can anyone make a suggestion on whether I'll be ok having the form hidden (the form contains one small graphic and 3 labels if that makes a difference) or is there a way to close that form but still be able to call it again from the parent form?

    Thanks.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    If you close() a form, its done. You would have to start all over.
    Hide()'ing the form is a better method if it gets used regularly. If the form is hardly ever used, it MIGHT be better to close/dispose/start over with a new one when you need it.

    Comment

    • Fuzz13
      New Member
      • Jun 2010
      • 110

      #3
      "If you close() a form, its done."
      I think that says it most perfectly. I went ahead and used the hide method. Thank you for explaining that for me.

      Comment

      Working...