Click to See Complete Forum and Search --> : Why can't I close the form in OnLoad event handler?


Sin Jeong-hun
September 29th, 2002, 12:59 AM
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.

MRutledge
September 30th, 2002, 07:36 PM
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.