Is there a guarantee that the Load event if an UserControl always occurs after the InitializeComponent() method and the constructor have been completed?
Is there a guarantee that the Load event if an UserControl always occurs after
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. The Load event runs right after the Handle is created. It is possible for the constructor to use a property of a control that requires the physical window to be created. That automatically triggers the CreateHandle() method, Load is next.
This is rare and usually a mistake. It tends to come to a good end, depending on what is being done in the event handler. Which ought to only ever do the kind of things that require the window. That’s not common, anything else belongs in the constructor. The constructor however hasn’t finished yet so you are working with a partially initialized object. Accidents are possible.