Property in a Windows Forms form class only accessable after Load event
Posted
by Spooky2010
on Stack Overflow
See other posts from Stack Overflow
or by Spooky2010
Published on 2010-03-02T08:53:27Z
Indexed on
2010/04/10
6:13 UTC
Read the original article
Hit count: 273
I'm instantiating and calling Form B from Form A. FormB has some custom properties, to allow me to pass it things like sqlAdaptors and dataset instances.
When i instantiate and show Form B from Form A as a dialog form with a Using statement, it all works fine, but i find the properties i pass are not available in Form B until after the form_load event has fired.
I was under the impression the properties when passed to a instantiated class should be available from a constructor, but this is not the case. If it try to access the properties before the form load event i get a null reference exception.
Is this correct behavior ?
© Stack Overflow or respective owner