CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2001
    Location
    South Korea
    Posts
    31

    Why can't I close the form in OnLoad event handler?

    In the form's OnLoad event handler, I tried to call form's Close() method,(because there were some errors in data so the form can't continue its job) but an exception was thrown.

    System.InvalidOperationException
    Can't call Close() while doing CreateHandle()

    What's wrong? How can I close the form then?
    Thank you.
    ALEA JACTA EST ET TEMPUS FUGIT

  2. #2
    Join Date
    Oct 1999
    Location
    Colorado
    Posts
    288
    You would have to call Close() after the form has been initialized...it is trying to create and destroy the form at the same time...that is why you are getting the error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured