C# property in a form class only accessable after formload 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:03 UTC
Read the original article
Hit count: 246
using vs2008, c#
Howdy,
Im 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 ? It is very annoying.
thanks for any help
© Stack Overflow or respective owner