C# Custom Control Properties load before Load and arrays are empties
Posted
by Wildhorn
on Stack Overflow
See other posts from Stack Overflow
or by Wildhorn
Published on 2010-06-16T14:16:22Z
Indexed on
2010/06/16
14:42 UTC
Read the original article
Hit count: 260
Hello, I made a custom control with custom properties.
When I modify these properties in the "Form.cs [Design]", I need stuff to happens (it fill some arrays and modify the look of the control), so I call a function within the "set" of the property. All of this works good.
My problem is that when I run the program with my custom control, it seems that properties "set" is called, which will call the function, but then, my arrays seems now to have lost all their values and the function use these arrays, but now because they are all empty, it crashes due to NullException blahblahblah. It also seems that properties "set" is called before the control Load (which I guess is called only when it is added to my Form, and not when the Form load).
So question is, why does my arrays become empty once I try to run the Form and is there an event that is called before that when the Form load?
Thanks
© Stack Overflow or respective owner